Sha256: a4941b10642547af6a475b44ea5e03a5a761f757d3c43a732164d32a35848a18

Contents?: true

Size: 1.19 KB

Versions: 16

Compression:

Stored size: 1.19 KB

Contents

# frozen_string_literal: true

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 { expect { subject.show(nil) }.to raise_error(FinAppsCore::MissingArgumentsError, 'Missing argument: token') }
    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') { expect(results).to be_a(Hashie::Mash::Rash) }
      it('results contains a consumer_id') { expect(results).to respond_to(:consumer_id) }
      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') { expect(error_messages.first.downcase).to eq('resource not found') }
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
finapps-4.0.3 spec/rest/order_tokens_spec.rb
finapps-4.0.2 spec/rest/order_tokens_spec.rb
finapps-4.0.1 spec/rest/order_tokens_spec.rb
finapps-3.0.7 spec/rest/order_tokens_spec.rb
finapps-3.0.6 spec/rest/order_tokens_spec.rb
finapps-3.0.5 spec/rest/order_tokens_spec.rb
finapps-3.0.4 spec/rest/order_tokens_spec.rb
finapps-3.0.3 spec/rest/order_tokens_spec.rb
finapps-3.0.2 spec/rest/order_tokens_spec.rb
finapps-3.0.1 spec/rest/order_tokens_spec.rb
finapps-2.3.7 spec/rest/order_tokens_spec.rb
finapps-2.3.6 spec/rest/order_tokens_spec.rb
finapps-2.3.5 spec/rest/order_tokens_spec.rb
finapps-2.3.3 spec/rest/order_tokens_spec.rb
finapps-2.3.2 spec/rest/order_tokens_spec.rb
finapps-2.3.1 spec/rest/order_tokens_spec.rb