Sha256: 75ed4d60ad335691ae6e6c15c45bb8a42f051912593a9d0a454ef7b1e9e5274e

Contents?: true

Size: 990 Bytes

Versions: 1

Compression:

Stored size: 990 Bytes

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")

      expect(described_class.new(response).to_s).to eq("Oauth2ApiClient::ResponseError (401): 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

1 entries across 1 versions & 1 rubygems

Version Path
oauth2_api_client-3.0.0 spec/oauth2_api_client/response_error_spec.rb