Sha256: 3e287c2789f899d6f0fd2c1879476105510afdf293f3b0cd2047fafbb0680a59

Contents?: true

Size: 1.65 KB

Versions: 28

Compression:

Stored size: 1.65 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') do
        expect { update }.to raise_error(FinAppsCore::MissingArgumentsError)
      end
    end

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

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

    context 'with invalid operator' do
      let(:update) { subject.update(:invalid_id, %w[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, %w[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

28 entries across 28 versions & 1 rubygems

Version Path
finapps-5.0.32 spec/rest/order_assignments_spec.rb
finapps-5.0.31 spec/rest/order_assignments_spec.rb
finapps-5.0.30 spec/rest/order_assignments_spec.rb
finapps-5.0.29 spec/rest/order_assignments_spec.rb
finapps-5.0.28 spec/rest/order_assignments_spec.rb
finapps-5.0.27 spec/rest/order_assignments_spec.rb
finapps-5.0.26 spec/rest/order_assignments_spec.rb
finapps-5.0.25 spec/rest/order_assignments_spec.rb
finapps-5.0.24 spec/rest/order_assignments_spec.rb
finapps-5.0.23 spec/rest/order_assignments_spec.rb
finapps-5.0.22 spec/rest/order_assignments_spec.rb
finapps-5.0.21 spec/rest/order_assignments_spec.rb
finapps-5.0.20 spec/rest/order_assignments_spec.rb
finapps-5.0.19 spec/rest/order_assignments_spec.rb
finapps-5.0.17 spec/rest/order_assignments_spec.rb
finapps-5.0.16 spec/rest/order_assignments_spec.rb
finapps-5.0.15 spec/rest/order_assignments_spec.rb
finapps-5.0.14 spec/rest/order_assignments_spec.rb
finapps-5.0.13 spec/rest/order_assignments_spec.rb
finapps-5.0.12 spec/rest/order_assignments_spec.rb