Sha256: 9dbbc8c3499ef2de82073d60adf12e4de3b8baf649ee237fe6b6506ab2fa9cf2

Contents?: true

Size: 1.42 KB

Versions: 32

Compression:

Stored size: 1.42 KB

Contents

# frozen_string_literal: true

require 'spec_helpers/client'

RSpec.describe FinApps::REST::OrderReports do
  include SpecHelpers::Client

  let(:order_report) { FinApps::REST::OrderReports.new client }

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

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

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

    context 'when valid params are provided' do
      subject { order_report.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 { order_report.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

32 entries across 32 versions & 1 rubygems

Version Path
finapps-5.0.3 spec/rest/order_reports_spec.rb
finapps-5.0.2 spec/rest/order_reports_spec.rb
finapps-5.0.1 spec/rest/order_reports_spec.rb
finapps-5.0.0 spec/rest/order_reports_spec.rb
finapps-4.0.16 spec/rest/order_reports_spec.rb
finapps-4.0.15 spec/rest/order_reports_spec.rb
finapps-4.0.14 spec/rest/order_reports_spec.rb
finapps-4.0.12 spec/rest/order_reports_spec.rb
finapps-4.0.11 spec/rest/order_reports_spec.rb
finapps-4.0.10 spec/rest/order_reports_spec.rb
finapps-4.0.9 spec/rest/order_reports_spec.rb
finapps-4.0.8 spec/rest/order_reports_spec.rb
finapps-4.0.7 spec/rest/order_reports_spec.rb
finapps-4.0.6 spec/rest/order_reports_spec.rb
finapps-4.0.5 spec/rest/order_reports_spec.rb
finapps-4.0.4 spec/rest/order_reports_spec.rb
finapps-4.0.3 spec/rest/order_reports_spec.rb
finapps-4.0.2 spec/rest/order_reports_spec.rb
finapps-4.0.1 spec/rest/order_reports_spec.rb
finapps-3.0.7 spec/rest/order_reports_spec.rb