Sha256: 22acedac4b775311379fc4322f51578dff49584d43e8007026b192c8fe594523

Contents?: true

Size: 1.6 KB

Versions: 2

Compression:

Stored size: 1.6 KB

Contents

# frozen_string_literal: true
require 'spec_helpers/client'

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

  describe '#update' do
    subject(:order_assignments) { FinApps::REST::OrderAssignments.new(client) }
    let(:results) { update[RESULTS] }
    let(:error_messages) { update[ERROR_MESSAGES] }

    context 'when missing id' do
      let(:update) { subject.update(nil, []) }
      it('returns missing argument error') { expect { update }.to raise_error(FinAppsCore::MissingArgumentsError) }
    end

    context 'when missing params' do
      let(:update) { subject.update(:valid_id, nil) }
      it('returns missing argument error') { expect { update }.to raise_error(FinAppsCore::MissingArgumentsError) }
    end

    context 'with invalid params' do
      let(:update) { subject.update(:valid_id, params: 'params') }
      it('returns invalid argument error') { expect { update }.to raise_error(FinAppsCore::InvalidArgumentsError) }
    end

    context 'with invalid operator' do
      let(:update) { subject.update(:invalid_id, ['invalid']) }

      it { expect { update }.not_to raise_error }
      it('results is nil') { expect(results).to be_nil }
      it('error messages array is populated') do
        expect(error_messages.first.downcase).to eq('resource not found')
      end
    end

    context 'with valid params' do
      let(:update) { subject.update(:valid_id, ['valid']) }

      it { expect { update }.not_to raise_error }
      it('results is nil') { expect(results).to be_nil }
      it('error_messages array is empty') { expect(error_messages).to eq([]) }
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
finapps-2.2.22 spec/rest/order_assignments_spec.rb
finapps-2.2.21 spec/rest/order_assignments_spec.rb