Sha256: e7d75735807839c961f07c701425e1296e9d1f66757437b6491e728c40093851

Contents?: true

Size: 928 Bytes

Versions: 1

Compression:

Stored size: 928 Bytes

Contents

require 'spec_helper'
require 'creditsafe/messages'

RSpec.describe(Creditsafe::Messages) do
  describe "#for_code" do
    subject(:message) { described_class.for_code(code) }

    context "for a valid code" do
      let(:code) { "020101" }
      its(:code) { is_expected.to eq(code) }
      its(:message) { is_expected.to eq('Invalid credentials') }
    end

    context "for a code without leading zero" do
      let(:code) { "20101" }
      its(:code) { is_expected.to eq("0#{code}") }
      its(:message) { is_expected.to eq('Invalid credentials') }
    end

    context "for an unknown code" do
      let(:code) { "999999" }
      its(:code) { is_expected.to eq(code) }
      its(:message) { is_expected.to eq('Unknown error') }
    end

    context "for an empty code" do
      let(:code) { '' }
      it "was passed the wrong parameters" do
        expect { subject(:message) }.to raise_error
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
creditsafe-0.1.1 spec/creditsafe/messages_spec.rb