Sha256: 823820e13f2f25097b6cb12f76107e88643c36e40599373fdfe74c15c3aac627

Contents?: true

Size: 1.41 KB

Versions: 23

Compression:

Stored size: 1.41 KB

Contents

# frozen_string_literal: true

require 'spec_helpers/client'

RSpec.describe FinApps::REST::Statements do
  include SpecHelpers::Client
  subject { FinApps::REST::Statements.new(client) }

  describe '#show' do
    context 'when missing account_id' do
      let(:show) { subject.show(nil, 'valid_id') }
      it { expect { show }.to raise_error(FinAppsCore::MissingArgumentsError) }
    end

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

    context 'when valid ids are provided' do
      let(:show) { subject.show('valid_id', 'valid_id') }
      it { expect { show }.not_to raise_error }
      it('returns an array') { expect(show).to be_a(Array) }
      it('performs a get and returns the response') do
        expect(show[RESULTS]).to have_key(:data)
      end
      it('returns no error messages') do
        expect(show[ERROR_MESSAGES]).to be_empty
      end
    end

    context 'when invalid ids are provided' do
      let(:show) { subject.show('invalid_id', 'valid_id') }
      it { expect { show }.not_to raise_error }
      it('returns an array') { expect(show).to be_a(Array) }
      it('results is nil') { expect(show[RESULTS]).to be_nil }
      it('error messages array is populated') do
        expect(show[ERROR_MESSAGES].first.downcase).to eq('resource not found')
      end
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
finapps-5.0.27 spec/rest/statements_spec.rb
finapps-5.0.26 spec/rest/statements_spec.rb
finapps-5.0.25 spec/rest/statements_spec.rb
finapps-5.0.24 spec/rest/statements_spec.rb
finapps-5.0.23 spec/rest/statements_spec.rb
finapps-5.0.22 spec/rest/statements_spec.rb
finapps-5.0.21 spec/rest/statements_spec.rb
finapps-5.0.20 spec/rest/statements_spec.rb
finapps-5.0.19 spec/rest/statements_spec.rb
finapps-5.0.17 spec/rest/statements_spec.rb
finapps-5.0.16 spec/rest/statements_spec.rb
finapps-5.0.15 spec/rest/statements_spec.rb
finapps-5.0.14 spec/rest/statements_spec.rb
finapps-5.0.13 spec/rest/statements_spec.rb
finapps-5.0.12 spec/rest/statements_spec.rb
finapps-5.0.11 spec/rest/statements_spec.rb
finapps-5.0.10 spec/rest/statements_spec.rb
finapps-5.0.9 spec/rest/statements_spec.rb
finapps-5.0.8 spec/rest/statements_spec.rb
finapps-5.0.7 spec/rest/statements_spec.rb