spec/unit/contextio/api_spec.rb in contextio-1.7.1 vs spec/unit/contextio/api_spec.rb in contextio-1.7.2
- old
+ new
@@ -150,9 +150,25 @@
it "raises an API error with the body message" do
expect { subject }.to raise_error(ContextIO::API::Error, 'nope')
end
end
+ context "with a bad response that has a different body" do
+ before do
+ WebMock.stub_request(
+ :get,
+ 'https://api.context.io/2.0/test'
+ ).to_return(
+ status: 400,
+ body: JSON.dump('success' => false, 'feedback_code' => 'nope')
+ )
+ end
+
+ it "raises an API error with the body message" do
+ expect { subject }.to raise_error(ContextIO::API::Error, 'nope')
+ end
+ end
+
context "with a bad response that has no body" do
before do
WebMock.stub_request(
:get,
'https://api.context.io/2.0/test'