Sha256: a064fdfda772887f3c3df4ce0404410e3788e0dec84afd65938019d4800b459c

Contents?: true

Size: 1.01 KB

Versions: 8

Compression:

Stored size: 1.01 KB

Contents

require File.expand_path("../spec_helper", __dir__)

RSpec.describe Oauth2ApiClient::ResponseError do
  describe "#to_s" do
    it "returns the message" do
      response = double(code: 401, body: "unauthorized", uri: "http://example.com/")

      expect(described_class.new(response).to_s).to eq("Oauth2ApiClient::ResponseError (401, http://example.com/): unauthorized")
    end
  end

  describe ".for" do
    it "returns the exception class for the status code of the given response" do
      expect(described_class.for(double(code: 400, body: "body"))).to be_instance_of(Oauth2ApiClient::ResponseError::BadRequest)
      expect(described_class.for(double(code: 404, body: "body"))).to be_instance_of(Oauth2ApiClient::ResponseError::NotFound)
      expect(described_class.for(double(code: 500, body: "body"))).to be_instance_of(Oauth2ApiClient::ResponseError::InternalServerError)
      expect(described_class.for(double(code: 503, body: "body"))).to be_instance_of(Oauth2ApiClient::ResponseError::ServiceUnavailable)
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
oauth2_api_client-4.0.0 spec/oauth2_api_client/response_error_spec.rb
oauth2_api_client-3.4.1 spec/oauth2_api_client/response_error_spec.rb
oauth2_api_client-3.4.0 spec/oauth2_api_client/response_error_spec.rb
oauth2_api_client-3.3.0 spec/oauth2_api_client/response_error_spec.rb
oauth2_api_client-3.2.1 spec/oauth2_api_client/response_error_spec.rb
oauth2_api_client-3.2.0 spec/oauth2_api_client/response_error_spec.rb
oauth2_api_client-3.1.1 spec/oauth2_api_client/response_error_spec.rb
oauth2_api_client-3.1.0 spec/oauth2_api_client/response_error_spec.rb