Sha256: 273b52a67db46715c96245441b55e9cb91918f238cd0eb85c4f4b9db306b8784

Contents?: true

Size: 1.49 KB

Versions: 22

Compression:

Stored size: 1.49 KB

Contents

# frozen_string_literal: true
RSpec.describe FinApps::REST::OrderReports do
  let(:client) { FinApps::REST::Client.new(:company_token) }
  describe '#show' do
    context 'when missing id' do
      subject { FinApps::REST::OrderReports.new(client).show(nil, :pdf) }
      it { expect { subject }.to raise_error(FinAppsCore::MissingArgumentsError) }
    end

    context 'when missing format' do
      subject { FinApps::REST::OrderReports.new(client).show(:valid_id, nil) }
      it { expect { subject }.to raise_error(FinAppsCore::MissingArgumentsError) }
    end

    context 'when invalid format is provided' do
      subject { FinApps::REST::OrderReports.new(client).show(:valid_id, :xml) }
      it { expect { subject }.to raise_error(FinAppsCore::InvalidArgumentsError) }
    end

    context 'when valid params are provided' do
      subject { FinApps::REST::OrderReports.new(client).show(:valid_id, :json) }

      it { expect { subject }.not_to raise_error }
      it('performs a get and returns the response') { expect(subject[0]).to respond_to(:days_requested) }
      it('returns no error messages') { expect(subject[1]).to be_empty }
    end

    context 'when invalid id is provided' do
      subject { FinApps::REST::OrderReports.new(client).show(:invalid_id, :json) }

      it { expect { subject }.not_to raise_error }
      it('results is nil') { expect(subject[0]).to be_nil }
      it('error messages array is populated') { expect(subject[1].first.downcase).to eq('resource not found') }
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
finapps-2.2.22 spec/rest/order_reports_spec.rb
finapps-2.2.21 spec/rest/order_reports_spec.rb
finapps-2.2.20 spec/rest/order_reports_spec.rb
finapps-2.2.19 spec/rest/order_reports_spec.rb
finapps-2.2.18 spec/rest/order_reports_spec.rb
finapps-2.2.17 spec/rest/order_reports_spec.rb
finapps-2.2.16 spec/rest/order_reports_spec.rb
finapps-2.2.15 spec/rest/order_reports_spec.rb
finapps-2.2.14 spec/rest/order_reports_spec.rb
finapps-2.2.13 spec/rest/order_reports_spec.rb
finapps-2.2.12 spec/rest/order_reports_spec.rb
finapps-2.2.11 spec/rest/order_reports_spec.rb
finapps-2.2.10 spec/rest/order_reports_spec.rb
finapps-2.2.9 spec/rest/order_reports_spec.rb
finapps-2.2.8 spec/rest/order_reports_spec.rb
finapps-2.2.7 spec/rest/order_reports_spec.rb
finapps-2.2.6 spec/rest/order_reports_spec.rb
finapps-2.2.5 spec/rest/order_reports_spec.rb
finapps-2.2.4 spec/rest/order_reports_spec.rb
finapps-2.2.3 spec/rest/order_reports_spec.rb