spec/unit/intercom/request_spec.rb in intercom-3.7.3 vs spec/unit/intercom/request_spec.rb in intercom-3.7.4

- old
+ new

@@ -70,11 +70,10 @@ req = Intercom::Request.get(uri, "") req.handle_rate_limit=true req.expects(:sleep).never.with(any_parameters) req.execute(target_base_url=uri, username: "ted", secret: "") end - end describe "Application errors on failure" do let(:uri) {"https://api.intercom.io/conversations/reply"} @@ -82,9 +81,17 @@ # Use webmock to mock the HTTP request stub_request(:put, uri).\ to_return(status: [409, "Resource Already Exists"], headers: { 'X-RateLimit-Reset' => (Time.now.utc + 10).to_i.to_s }, body: {type: "error.list", errors: [ code: "resource_conflict" ]}.to_json) req = Intercom::Request.put(uri, "") expect { req.execute(target_base_url=uri, username: "ted", secret: "") }.must_raise(Intercom::ResourceNotUniqueError) + end + + it 'should raise ApiVersionInvalid error on intercom_version_invalid code' do + # Use webmock to mock the HTTP request + stub_request(:put, uri).\ + to_return(status: [400, "Bad Request"], headers: { 'X-RateLimit-Reset' => (Time.now.utc + 10).to_i.to_s }, body: {type: "error.list", errors: [ code: "intercom_version_invalid" ]}.to_json) + req = Intercom::Request.put(uri, "") + expect { req.execute(uri, username: "ted", secret: "") }.must_raise(Intercom::ApiVersionInvalid) end end it 'parse_body returns nil if decoded_body is nil' do response = OpenStruct.new(:code => 500)