Sha256: 9ff60da142ac6d408cc22773a06c05f6765d1a31bdb6f0a0f36b150b8938f303

Contents?: true

Size: 1.27 KB

Versions: 24

Compression:

Stored size: 1.27 KB

Contents

# frozen_string_literal: true

require 'spec_helpers/client'

RSpec.describe FinApps::REST::OrderTokens,
               'initialized with valid FinApps::Client object' do
  include SpecHelpers::Client

  describe '#show' do
    subject(:order_tokens) { FinApps::REST::OrderTokens.new(client) }
    let(:results) { show[RESULTS] }
    let(:error_messages) { show[ERROR_MESSAGES] }

    context 'when missing token' do
      it do
        expect { subject.show(nil) }.to raise_error(
          FinAppsCore::MissingArgumentsError,
          ': token'
        )
      end
    end

    context 'for valid token' do
      let(:show) { subject.show(:valid_token) }
      it { expect { show }.not_to raise_error }
      it('results is a Hash') { expect(results).to be_a(Hash) }
      it('results contains a consumer_id') do
        expect(results).to have_key(:consumer_id)
      end
      it('error_messages array is empty') { expect(error_messages).to eq([]) }
    end

    context 'for invalid token' do
      let(:show) { subject.show(:invalid_token) }
      it { expect { show }.not_to raise_error }
      it('results is nil') { expect(results).to be_nil }
      it('error messages array is populated') do
        expect(error_messages.first.downcase).to eq('resource not found')
      end
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
finapps-5.0.32 spec/rest/order_tokens_spec.rb
finapps-5.0.31 spec/rest/order_tokens_spec.rb
finapps-5.0.30 spec/rest/order_tokens_spec.rb
finapps-5.0.29 spec/rest/order_tokens_spec.rb
finapps-5.0.28 spec/rest/order_tokens_spec.rb
finapps-5.0.27 spec/rest/order_tokens_spec.rb
finapps-5.0.26 spec/rest/order_tokens_spec.rb
finapps-5.0.25 spec/rest/order_tokens_spec.rb
finapps-5.0.24 spec/rest/order_tokens_spec.rb
finapps-5.0.23 spec/rest/order_tokens_spec.rb
finapps-5.0.22 spec/rest/order_tokens_spec.rb
finapps-5.0.21 spec/rest/order_tokens_spec.rb
finapps-5.0.20 spec/rest/order_tokens_spec.rb
finapps-5.0.19 spec/rest/order_tokens_spec.rb
finapps-5.0.17 spec/rest/order_tokens_spec.rb
finapps-5.0.16 spec/rest/order_tokens_spec.rb
finapps-5.0.15 spec/rest/order_tokens_spec.rb
finapps-5.0.14 spec/rest/order_tokens_spec.rb
finapps-5.0.13 spec/rest/order_tokens_spec.rb
finapps-5.0.12 spec/rest/order_tokens_spec.rb