Sha256: 10215c1ff77306acd778916d0b2d62122b57d2407a25827a46f5861e1f011ca9

Contents?: true

Size: 1.27 KB

Versions: 3

Compression:

Stored size: 1.27 KB

Contents

# frozen_string_literal: true

require 'spec_helpers/client'

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

  describe '#create' do
    subject(:notifications) { FinApps::REST::DocumentsOrdersNotifications.new(client) }

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

    context 'when invalid id is provided' do
      let(:create) { subject.create(:invalid_id) }
      let(:results) { create[RESULTS] }
      let(:error_messages) { create[ERROR_MESSAGES] }

      it { expect { create }.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('order id is invalid')
      end
    end

    context 'for valid id' do
      let(:create) { subject.create(:valid_id) }
      let(:results) { create[RESULTS] }
      let(:error_messages) { create[ERROR_MESSAGES] }

      it { expect { create }.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

3 entries across 3 versions & 1 rubygems

Version Path
finapps-5.0.32 spec/rest/documents_orders_notifications_spec.rb
finapps-5.0.31 spec/rest/documents_orders_notifications_spec.rb
finapps-5.0.30 spec/rest/documents_orders_notifications_spec.rb