Sha256: 133caeb980fd6dca38e65037dbe79529ec0de01c602d94977575e209270249aa

Contents?: true

Size: 1.09 KB

Versions: 1

Compression:

Stored size: 1.09 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') { expect(subject[ERROR_MESSAGES].first.downcase).to eq('resource not found') }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
finapps-2.2.5 spec/rest/order_statuses_spec.rb