spec/bugsnag/api/client_spec.rb in bugsnag-api-1.0.3 vs spec/bugsnag/api/client_spec.rb in bugsnag-api-2.0.0
- old
+ new
@@ -42,29 +42,29 @@
before(:each) do
Bugsnag::Api.reset!
end
it "handles query params", :vcr do
- Bugsnag::Api.get "/", :foo => "bar"
+ Bugsnag::Api.get bugsnag_url("/"), :foo => "bar"
assert_requested :get, "https://api.bugsnag.com?foo=bar"
end
it "handles headers" do
request = stub_get("/zen").
with(:query => {:foo => "bar"}, :headers => {:accept => "text/plain"})
- Bugsnag::Api.get "/zen", :foo => "bar", :accept => "text/plain"
+ Bugsnag::Api.get bugsnag_url("/zen"), :foo => "bar", :accept => "text/plain"
assert_requested request
end
end
describe ".last_response", :vcr do
it "caches the last agent response" do
Bugsnag::Api.reset!
client = Bugsnag::Api.client
expect(client.last_response).to be_nil
- client.get "/"
+ client.get bugsnag_url("/")
expect(client.last_response.status).to eq(200)
end
end
describe ".basic_authenticated?" do
@@ -83,9 +83,14 @@
context "error handling" do
it "raises on 404" do
stub_get('/booya').to_return(:status => 404)
expect { Bugsnag::Api.get('/booya') }.to raise_error(Bugsnag::Api::NotFound)
+ end
+
+ it "raises on 429" do
+ stub_get('/test').to_return(:status => 429)
+ expect { Bugsnag::Api.get('/test') }.to raise_error(Bugsnag::Api::RateLimitExceeded)
end
it "raises on 500" do
stub_get('/boom').to_return(:status => 500)
expect { Bugsnag::Api.get('/boom') }.to raise_error(Bugsnag::Api::InternalServerError)