Sha256: a49eb31fd88bc7e2a929a93850a99d20a67651d94028c4302f83eebece6b5e1d

Contents?: true

Size: 1.2 KB

Versions: 14

Compression:

Stored size: 1.2 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 { expect { subject.show(nil) }.to raise_error(FinAppsCore::MissingArgumentsError, ': 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

14 entries across 14 versions & 1 rubygems

Version Path
finapps-5.0.3 spec/rest/order_tokens_spec.rb
finapps-5.0.2 spec/rest/order_tokens_spec.rb
finapps-5.0.1 spec/rest/order_tokens_spec.rb
finapps-5.0.0 spec/rest/order_tokens_spec.rb
finapps-4.0.16 spec/rest/order_tokens_spec.rb
finapps-4.0.15 spec/rest/order_tokens_spec.rb
finapps-4.0.14 spec/rest/order_tokens_spec.rb
finapps-4.0.12 spec/rest/order_tokens_spec.rb
finapps-4.0.11 spec/rest/order_tokens_spec.rb
finapps-4.0.10 spec/rest/order_tokens_spec.rb
finapps-4.0.9 spec/rest/order_tokens_spec.rb
finapps-4.0.8 spec/rest/order_tokens_spec.rb
finapps-4.0.7 spec/rest/order_tokens_spec.rb
finapps-4.0.6 spec/rest/order_tokens_spec.rb