Sha256: 2655b681bdc9bb822e18523191006cc3f06068a53f1e090030770a20f655e1a4

Contents?: true

Size: 1.56 KB

Versions: 9

Compression:

Stored size: 1.56 KB

Contents

require 'spec_helper'

describe Flinks::API::Statement do
  let(:api_endpoint) { Flinks::Client.dry_initializer.definitions[:api_endpoint].default.call }
  let(:client) { Flinks.new(customer_id: 'customer_id') }
  let(:request_id) { 'request_id' }

  describe '#statements' do
    before do
      stub_request(:post, /#{api_endpoint}/)
        .to_return(status: 200, body: "{}", headers: { 'Content-Type'=>'application/json' })
    end

    it "returns an object" do
      expect(client.statements).to be_a(Hash)
    end

    context "with valid options" do
      let(:options) do
        {
          accounts_filter: ['string'],
          number_of_statements: 'MostRecent',
          most_recent: true,
          most_recent_cached: true
        }
      end

      it "returns an object" do
        expect(client.statements(options: options)).to be_a(Hash)
      end
    end

    context "with invalid options" do
      let(:options) do
        {
          accounts_filter: 'invalid',
          number_of_statements: 'invalid',
          most_recent: 'invalid',
          most_recent_cached: 'invalid'
        }
      end

      it "raises an error" do
        expect {
          client.statements(options: options)
        }.to raise_error(ArgumentError)
      end
    end
  end

  describe '#statements_async' do
    before do
      stub_request(:get, /#{api_endpoint}/)
        .to_return(status: 200, body: "{}", headers: { 'Content-Type'=>'application/json' })
    end

    it "returns an object" do
      expect(client.statements_async(request_id: request_id)).to be_a(Hash)
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
flinks-0.5.2 spec/lib/api/statement_spec.rb
flinks-0.5.1 spec/lib/api/statement_spec.rb
flinks-0.5.0 spec/lib/api/statement_spec.rb
flinks-0.4.2 spec/lib/api/statement_spec.rb
flinks-0.3.1 spec/lib/api/statement_spec.rb
flinks-0.3.0 spec/lib/api/statement_spec.rb
flinks-0.2.0 spec/lib/api/statement_spec.rb
flinks-0.1.1 spec/lib/api/statement.rb
flinks-0.1.0 spec/lib/api/statement.rb