Skip to content

Commit 00bed83

Browse files
authored
Merge pull request #281 from psu-libraries/hotfix-keyword-args
Convert AWS config to keyword arguments
2 parents eadf1ca + 8673e5f commit 00bed83

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

app/jobs/image_alt_text_job.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def resolve_llm_model
4949
end
5050

5151
def alt_text_client
52-
@alt_text_client ||= AltText::Client.new(alt_text_client_config)
52+
@alt_text_client ||= AltText::Client.new(**alt_text_client_config)
5353
end
5454

5555
def alt_text_client_config

spec/jobs/image_alt_text_job_spec.rb

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,17 @@
1515
'image/jpg',
1616
original_filename: 'lion.jpg').path }
1717

18+
around do |example|
19+
ClimateControl.modify(
20+
'AWS_ACCESS_KEY_ID' => 'test-access-key',
21+
'AWS_SECRET_ACCESS_KEY' => 'test-secret-key',
22+
'AWS_REGION' => 'test-region',
23+
'LLM_MODEL' => 'test-llm-model'
24+
) do
25+
example.run
26+
end
27+
end
28+
1829
before do
1930
allow(AltText::Client).to receive(:new).and_return alt_text_gem
2031
allow(AltText::LLMRegistry).to receive(:resolve).and_return 'resolved-model-name'
@@ -28,7 +39,15 @@
2839

2940
it 'calls the Alt Text gem' do
3041
expect(alt_text_gem).to have_received(:process_image).with(
31-
/.+\.jpg/, prompt: File.read('prompt.txt'), model_id: ENV.fetch('LLM_MODEL', 'default')
42+
/.+\.jpg/, prompt: File.read('prompt.txt'), model_id: 'test-llm-model'
43+
)
44+
end
45+
46+
it 'initializes AltText::Client with ENV-based config' do
47+
expect(AltText::Client).to have_received(:new).with(
48+
access_key: 'test-access-key',
49+
secret_key: 'test-secret-key',
50+
region: 'test-region'
3251
)
3352
end
3453

0 commit comments

Comments
 (0)