File tree Expand file tree Collapse file tree 1 file changed +0
-25
lines changed Expand file tree Collapse file tree 1 file changed +0
-25
lines changed Original file line number Diff line number Diff line change 153153 end
154154 end
155155
156- context "when OpenAI returns an HTTP error" do
157- let ( :chunk ) { "{\" error\" :{\" message\" :\" A bad thing has happened!\" }}" }
158- let ( :env ) do
159- Faraday ::Env . new (
160- status : 500 ,
161- url : URI ::HTTPS . build ( host : "api.openai.com" ) ,
162- request : Faraday ::RequestOptions . new
163- )
164- end
165-
166- it "does not raise an error and calls the user proc with the error parsed as JSON" do
167- expect ( user_proc ) . to receive ( :call ) . with (
168- {
169- "error" => {
170- "message" => "A bad thing has happened!"
171- }
172- }
173- )
174-
175- expect do
176- stream . call ( chunk , 0 , env )
177- end . not_to raise_error
178- end
179- end
180-
181156 context "when called with JSON split across chunks" do
182157 it "calls the user proc with the data parsed as JSON" do
183158 expect ( user_proc ) . to receive ( :call ) . with ( JSON . parse ( '{ "foo": "bar" }' ) )
You can’t perform that action at this time.
0 commit comments