Sha256: 4f4fcb83902970bb30117b8362214e482ce3c1a8430a25c3e5a7b2880c2e53f0

Contents?: true

Size: 1.1 KB

Versions: 4

Compression:

Stored size: 1.1 KB

Contents

# frozen_string_literal: true
RSpec.describe FinApps::REST::OrderStatuses do
  include SpecHelpers::Client

  RESULTS = 0
  ERROR_MESSAGES = 1

  describe '#show' do
    context 'when missing id' do
      subject { FinApps::REST::OrderStatuses.new(client).show(nil) }
      it { expect { subject }.to raise_error(FinAppsCore::MissingArgumentsError) }
    end

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

      it { expect { subject }.not_to raise_error }
      it('performs a get and returns the response') { expect(subject[RESULTS]).to respond_to(:status) }
      it('returns no error messages') { expect(subject[ERROR_MESSAGES]).to be_empty }
    end

    context 'when invalid id is provided' do
      subject { FinApps::REST::OrderStatuses.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

4 entries across 4 versions & 1 rubygems

Version Path
finapps-2.2.9 spec/rest/order_statuses_spec.rb
finapps-2.2.8 spec/rest/order_statuses_spec.rb
finapps-2.2.7 spec/rest/order_statuses_spec.rb
finapps-2.2.6 spec/rest/order_statuses_spec.rb