Sha256: c2be266f68f7b226a6a2fbf2fec340cdf381aaaf7a9556f8d6d8aeacc8110c5c

Contents?: true

Size: 949 Bytes

Versions: 2

Compression:

Stored size: 949 Bytes

Contents

# frozen_string_literal: true

RSpec.describe SolidusSubscriptions::Dispatcher::SuccessDispatcher do
  describe '#dispatch' do
    it 'marks the installment as success' do
      installment = instance_spy(SolidusSubscriptions::Installment)
      order = create(:order_with_line_items)

      dispatcher = described_class.new(installment, order)
      dispatcher.dispatch

      expect(installment).to have_received(:success!).with(order)
    end

    it 'fires an installments_succeeded event' do
      stub_const('Spree::Event', class_spy(Spree::Event))
      installment = instance_spy(SolidusSubscriptions::Installment)
      order = create(:order_with_line_items)

      dispatcher = described_class.new(installment, order)
      dispatcher.dispatch

      expect(Spree::Event).to have_received(:fire).with(
        'solidus_subscriptions.installment_succeeded',
        installment: installment,
        order: order,
      )
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
solidus_subscriptions-1.0.0 spec/lib/solidus_subscriptions/dispatcher/success_dispatcher_spec.rb
solidus_subscriptions-1.0.0.rc1 spec/lib/solidus_subscriptions/dispatcher/success_dispatcher_spec.rb