Sha256: 3dcdbd2de0893607caa2b536516970b54b7c92f3aa4e738e773f33ebc6e41e53

Contents?: true

Size: 1.23 KB

Versions: 5

Compression:

Stored size: 1.23 KB

Contents

require "spec_helper"

RSpec.describe Mundipagg::Response do
  describe "#success?" do
    context "when true" do
      subject { described_class.new success: true }
      it { expect(subject).to be_success }
    end

    context "when false" do
      subject { described_class.new success: false }
      it { expect(subject).to_not be_success }
    end

    context "when nil" do
      it { expect(subject).to_not be_success }
    end
  end

  describe "#error_item" do
    it { expect { subject.error_item }.to raise_error("Not yet implemented") }
  end

  describe "#error" do
    context "when error_item is present" do
      before do
        allow(subject).to receive(:error_item).and_return({ description: "Error", error_code: 0 })
      end

      it { expect(subject.error).to be_a(Mundipagg::Error) }
      it { expect(subject.error.message).to eq("Error") }
      it { expect(subject.error.code).to eq(0) }
    end

    context "when error_item is not present" do
      before do
        allow(subject).to receive(:error_item).and_return(nil)
      end

      it { expect(subject.error).to be_a(Mundipagg::Error) }
      it { expect(subject.error.message).to eq("Unknown error") }
      it { expect(subject.error.code).to eq(0) }
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
better-mundipagg-0.2.11 spec/lib/mundipagg/response_spec.rb
better-mundipagg-0.2.10 spec/lib/mundipagg/response_spec.rb
better-mundipagg-0.2.9 spec/lib/mundipagg/response_spec.rb
better-mundipagg-0.2.8 spec/lib/mundipagg/response_spec.rb
better-mundipagg-0.2.7 spec/lib/mundipagg/response_spec.rb