Skip to content

Commit 2f7cfb7

Browse files
committed
Separate mocked VCR cassettes
1 parent 2be9bf8 commit 2f7cfb7

File tree

5 files changed

+118
-6
lines changed

5 files changed

+118
-6
lines changed

spec/fixtures/cassettes/mocks/gpt-3_5-turbo_streamed_chat_with_error_response.yml

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

spec/fixtures/cassettes/mocks/gpt-3_5-turbo_streamed_chat_with_json_error_response.yml

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

spec/fixtures/cassettes/mocks/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/chat_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ def call(chunk)
129129
end
130130

131131
context "with an error response with a JSON body" do
132-
let(:cassette) { "#{model} streamed chat with json error response".downcase }
132+
let(:cassette) { "mocks/#{model} streamed chat with json error response".downcase }
133133

134134
it "raises an HTTP error with the parsed body" do
135135
VCR.use_cassette(cassette, record: :none) do
@@ -151,7 +151,7 @@ def call(chunk)
151151
end
152152

153153
context "with an error response without a JSON body" do
154-
let(:cassette) { "#{model} streamed chat with error response".downcase }
154+
let(:cassette) { "mocks/#{model} streamed chat with error response".downcase }
155155

156156
it "raises an HTTP error" do
157157
VCR.use_cassette(cassette, record: :none) do

spec/openai/client/http_spec.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@
106106

107107
describe ".get" do
108108
context "with an error response" do
109-
let(:cassette) { "http get with error response".downcase }
109+
let(:cassette) { "mocks/http get with error response".downcase }
110110

111111
it "raises an HTTP error" do
112112
VCR.use_cassette(cassette, record: :none) do
@@ -189,10 +189,10 @@
189189
end
190190
end
191191

192-
describe ".parse_jsonl" do
192+
describe ".parse_json" do
193193
context "with a jsonl string" do
194194
let(:body) { "{\"prompt\":\":)\"}\n{\"prompt\":\":(\"}\n" }
195-
let(:parsed) { OpenAI::Client.new.send(:parse_jsonl, body) }
195+
let(:parsed) { OpenAI::Client.new.send(:parse_json, body) }
196196

197197
it { expect(parsed).to eq([{ "prompt" => ":)" }, { "prompt" => ":(" }]) }
198198
end
@@ -285,7 +285,7 @@
285285
end
286286

287287
describe "logging errors" do
288-
let(:cassette) { "http get with error response".downcase }
288+
let(:cassette) { "mocks/http get with error response".downcase }
289289

290290
before do
291291
@original_stdout = $stdout

0 commit comments

Comments
 (0)