Sha256: 002ad0086476ae2d4f5140ffe09f5fbeaa8b4413c1da76b4d8330261d12ccb74

Contents?: true

Size: 888 Bytes

Versions: 9

Compression:

Stored size: 888 Bytes

Contents

require "helper"

RSpec.describe Affirm::FailureResult do
  let(:body) do
    {
      "status_code" => 400,
      "type"        => "invalid_request",
      "code"        => "invalid_field",
      "message"     => "An input field resulted in invalid request.",
      "field"       => "foo"
    }
  end

  let(:response) do
    double(:response, status: 400, success?: false, body: body)
  end

  subject { described_class.new(response) }

  context "response" do
    it "should have status" do
      expect(subject.status).to eq(response.status)
    end

    it "should not be successful" do
      expect(subject).not_to be_success
    end
  end

  context "error object" do
    %w(
      status_code
      type
      code
      message
      field
    ).each do |method|
      it method do
        expect(subject.error.public_send(method)).to eq(body[method])
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
affirm-ruby-1.2.0 spec/failure_result_spec.rb
affirm-ruby-1.1.3 spec/failure_result_spec.rb
affirm-ruby-1.1.2 spec/failure_result_spec.rb
affirm-ruby-1.1.1 spec/failure_result_spec.rb
affirm-ruby-1.1.0 spec/failure_result_spec.rb
affirm-ruby-1.0.2 spec/failure_result_spec.rb
affirm-ruby-1.0.1 spec/failure_result_spec.rb
affirm-ruby-1.0.0 spec/failure_result_spec.rb
affirm-ruby-0.0.1 spec/failure_result_spec.rb