Sha256: 0e44d598cb13107d1a41b1c1526e472ffc9a643303356d64ebd182fff28f5777

Contents?: true

Size: 1.1 KB

Versions: 2

Compression:

Stored size: 1.1 KB

Contents

# frozen_string_literal: true

RSpec.describe FinApps::REST::OrderStatuses do
  include SpecHelpers::Client

  describe '#show' do
    context 'when missing id' do
      subject { described_class.new(client).show(nil) }

      it do
        expect { subject }.to raise_error(FinAppsCore::MissingArgumentsError)
      end
    end

    context 'when valid id is provided' do
      subject { described_class.new(client).show(:valid_id) }

      it { expect { subject }.not_to raise_error }

      it('performs a get and returns the response') do
        expect(subject[RESULTS]).to have_key(:status)
      end

      it('returns no error messages') do
        expect(subject[ERROR_MESSAGES]).to be_empty
      end
    end

    context 'when invalid id is provided' do
      subject { described_class.new(client).show(:invalid_id) }

      it { expect { subject }.not_to raise_error }
      it('results is nil') { expect(subject[RESULTS]).to be_nil }

      it('error messages array is populated') do
        expect(subject[ERROR_MESSAGES].first.downcase).to eq(
          'resource not found'
        )
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
finapps-5.0.34 spec/rest/order_statuses_spec.rb
finapps-5.0.33 spec/rest/order_statuses_spec.rb