Skip to content

Commit 61970cd

Browse files
committed
Add spec for GET error
1 parent 038a81f commit 61970cd

File tree

2 files changed

+57
-0
lines changed

2 files changed

+57
-0
lines changed

spec/fixtures/cassettes/http_get_with_error_response.yml

Lines changed: 41 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

spec/openai/client/http_spec.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,22 @@
9696
end
9797
end
9898

99+
describe ".get" do
100+
context "with an error response" do
101+
let(:cassette) { "http get with error response".downcase }
102+
103+
it "raises an HTTP error" do
104+
VCR.use_cassette(cassette) do
105+
OpenAI::Client.new.models.retrieve(id: "text-ada-001")
106+
rescue Faraday::Error => e
107+
expect(e.response).to include(status: 400)
108+
else
109+
raise "Expected to raise Faraday::BadRequestError"
110+
end
111+
end
112+
end
113+
end
114+
99115
describe ".to_json_stream" do
100116
context "with a proc" do
101117
let(:user_proc) { proc { |x| x } }

0 commit comments

Comments
 (0)