Sha256: e9b58038f59603be8aea0f36db72bffac9600942a68c317bc67290211e572e78

Contents?: true

Size: 1.3 KB

Versions: 4

Compression:

Stored size: 1.3 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 Hashie::Rash') do
        expect(results).to be_a(Hash)
      end
      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

4 entries across 4 versions & 1 rubygems

Version Path
finapps-5.0.7 spec/rest/order_tokens_spec.rb
finapps-5.0.6 spec/rest/order_tokens_spec.rb
finapps-5.0.5 spec/rest/order_tokens_spec.rb
finapps-5.0.4 spec/rest/order_tokens_spec.rb