Sha256: 2589d5d418e396a421cf9c1791b1ed9fe67ad7e9580c5bf1f44e98b840349acf

Contents?: true

Size: 951 Bytes

Versions: 4

Compression:

Stored size: 951 Bytes

Contents

describe Moip2::Response do
  let(:parsed_json) { { "id" => "ORD-SOMETHING" } }

  let(:response) { described_class.new(nil, parsed_json) }

  describe "method delegation" do
    it "delegates []" do
      expect(response["id"]).to eq("ORD-SOMETHING")
    end

    it "delegates attribute to property accessor" do
      expect(response.id).to eq("ORD-SOMETHING")
    end
  end

  describe "#success?" do
    let(:success_response) do
      double("Success Response", code: 200)
    end

    let(:response) { described_class.new(success_response, parsed_json) }

    it "returns true when response code == 2xx" do
      expect(response).to be_success
    end
  end

  describe "#client_error?" do
    let(:error_response) do
      double("Error Response", code: 400)
    end

    let(:response) { described_class.new(error_response, {}) }

    it "returns false when response code == 4xx" do
      expect(response).to be_client_error
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
moip2-1.3.1 spec/moip2/response_spec.rb
moip2-1.2.1 spec/moip2/response_spec.rb
moip2-1.2.0 spec/moip2/response_spec.rb
moip2-1.1.0 spec/moip2/response_spec.rb