Sha256: 18162cce0308c8fbabccbc781d058bf8058f768ffc5ff8824edb1d8472c3dc8e

Contents?: true

Size: 1.25 KB

Versions: 6

Compression:

Stored size: 1.25 KB

Contents

# frozen_string_literal: true

require 'spec_helpers/client'

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

  describe '#create' do
    subject(:notifications) { described_class.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 'with 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

6 entries across 6 versions & 1 rubygems

Version Path
finapps-5.0.44 spec/rest/documents_orders_notifications_spec.rb
finapps-5.0.43 spec/rest/documents_orders_notifications_spec.rb
finapps-5.0.41 spec/rest/documents_orders_notifications_spec.rb
finapps-5.0.38 spec/rest/documents_orders_notifications_spec.rb
finapps-5.0.36 spec/rest/documents_orders_notifications_spec.rb
finapps-5.0.35 spec/rest/documents_orders_notifications_spec.rb