|
78 | 78 | end
|
79 | 79 |
|
80 | 80 | describe '#refresh!' do
|
81 |
| - it 'updates models and returns a chainable Models instance' do # rubocop:disable RSpec/ExampleLength,RSpec/MultipleExpectations |
82 |
| - # Use a temporary file to avoid modifying actual models.json |
83 |
| - temp_file = Tempfile.new(['models', '.json']) |
84 |
| - allow(File).to receive(:expand_path).with('models.json', any_args).and_return(temp_file.path) |
85 |
| - |
86 |
| - begin |
87 |
| - # Refresh and chain immediately |
88 |
| - chat_models = RubyLLM.models.refresh!.chat_models |
89 |
| - |
90 |
| - # Verify we got results |
91 |
| - expect(chat_models).to be_a(described_class) |
92 |
| - expect(chat_models.all).to all(have_attributes(type: 'chat')) |
93 |
| - |
94 |
| - # Verify we got models from at least OpenAI and Anthropic |
95 |
| - providers = chat_models.map(&:provider).uniq |
96 |
| - expect(providers).to include('openai', 'anthropic') |
97 |
| - ensure |
98 |
| - temp_file.close |
99 |
| - temp_file.unlink |
100 |
| - end |
101 |
| - end |
| 81 | + it 'updates models and returns a chainable Models instance' do # rubocop:disable RSpec/MultipleExpectations |
| 82 | + # Refresh and chain immediately |
| 83 | + chat_models = RubyLLM.models.refresh!.chat_models |
102 | 84 |
|
103 |
| - it 'works as a class method too' do # rubocop:disable RSpec/ExampleLength |
104 |
| - temp_file = Tempfile.new(['models', '.json']) |
105 |
| - allow(File).to receive(:expand_path).with('models.json', any_args).and_return(temp_file.path) |
| 85 | + # Verify we got results |
| 86 | + expect(chat_models).to be_a(described_class) |
| 87 | + expect(chat_models.all).to all(have_attributes(type: 'chat')) |
106 | 88 |
|
107 |
| - begin |
108 |
| - # Call class method |
109 |
| - described_class.refresh! |
| 89 | + # Verify we got models from at least OpenAI and Anthropic |
| 90 | + providers = chat_models.map(&:provider).uniq |
| 91 | + expect(providers).to include('openai', 'anthropic') |
| 92 | + end |
110 | 93 |
|
111 |
| - # Verify singleton instance was updated |
112 |
| - expect(RubyLLM.models.all.size).to be > 0 |
113 |
| - ensure |
114 |
| - temp_file.close |
115 |
| - temp_file.unlink |
116 |
| - end |
| 94 | + it 'works as a class method too' do |
| 95 | + described_class.refresh! |
| 96 | + |
| 97 | + # Verify singleton instance was updated |
| 98 | + expect(RubyLLM.models.all.size).to be > 0 |
117 | 99 | end
|
118 | 100 | end
|
119 | 101 |
|
|
0 commit comments