Sha256: a738f139c859c08dda877ffc176a88e66f77490360cf88614b6e75113de1d055

Contents?: true

Size: 1.34 KB

Versions: 40

Compression:

Stored size: 1.34 KB

Contents

# frozen_string_literal: true

require 'spec_helpers/client'

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

    describe '#show' do
      subject(:order_tokens) { described_class.new(client) }

      let(:results) { show[RESULTS] }
      let(:error_messages) { show[ERROR_MESSAGES] }

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

      context 'with 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 'with 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
end

Version data entries

40 entries across 40 versions & 1 rubygems

Version Path
finapps-6.13.1 spec/rest/order_tokens_spec.rb
finapps-6.13.0 spec/rest/order_tokens_spec.rb
finapps-6.12.0 spec/rest/order_tokens_spec.rb
finapps-6.11.0 spec/rest/order_tokens_spec.rb
finapps-6.10.2 spec/rest/order_tokens_spec.rb
finapps-6.10.1 spec/rest/order_tokens_spec.rb
finapps-6.10.0 spec/rest/order_tokens_spec.rb
finapps-6.9.2 spec/rest/order_tokens_spec.rb
finapps-6.9.1 spec/rest/order_tokens_spec.rb
finapps-6.9.0 spec/rest/order_tokens_spec.rb
finapps-6.8.0 spec/rest/order_tokens_spec.rb
finapps-6.7.1 spec/rest/order_tokens_spec.rb
finapps-6.7.0 spec/rest/order_tokens_spec.rb
finapps-6.6.1 spec/rest/order_tokens_spec.rb
finapps-6.6.0 spec/rest/order_tokens_spec.rb
finapps-6.5.0 spec/rest/order_tokens_spec.rb
finapps-6.4.3 spec/rest/order_tokens_spec.rb
finapps-6.4.2 spec/rest/order_tokens_spec.rb
finapps-6.4.1 spec/rest/order_tokens_spec.rb
finapps-6.4.0 spec/rest/order_tokens_spec.rb