Sha256: ed9a0fbdb9e89198be1a17196ac2dc25bec4f7498cbf5be8120063d77f5219b4

Contents?: true

Size: 868 Bytes

Versions: 8

Compression:

Stored size: 868 Bytes

Contents

# frozen_string_literal: true

RSpec.describe SolidusSupport::LegacyEventCompat::Bus do
  describe '#publish' do
    if SolidusSupport::LegacyEventCompat.using_legacy?
      it 'forwards to Spree::Event' do
        box = nil
        subscription = Spree::Event.subscribe(:foo) { |event| box = event.payload[:bar] }

        described_class.publish(:foo, bar: :baz)

        expect(box).to be(:baz)
      ensure
        Spree::Event.unsubscribe(subscription)
      end
    else
      it 'forwards to Spree::Bus' do
        box = nil
        Spree::Bus.register(:foo)
        subscription = Spree::Bus.subscribe(:foo) { |event| box = event.payload[:bar] }

        described_class.publish(:foo, bar: :baz)

        expect(box).to be(:baz)
      ensure
        Spree::Bus.unsubscribe(subscription)
        Spree::Bus.registry.unregister(:foo)
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
solidus_support-0.10.3 spec/solidus_support/legacy_event_compat/bus_spec.rb
solidus_support-0.10.2 spec/solidus_support/legacy_event_compat/bus_spec.rb
solidus_support-0.10.1 spec/solidus_support/legacy_event_compat/bus_spec.rb
solidus_support-0.10.0 spec/solidus_support/legacy_event_compat/bus_spec.rb
solidus_support-0.9.3 spec/solidus_support/legacy_event_compat/bus_spec.rb
solidus_support-0.9.2 spec/solidus_support/legacy_event_compat/bus_spec.rb
solidus_support-0.9.1 spec/solidus_support/legacy_event_compat/bus_spec.rb
solidus_support-0.9.0 spec/solidus_support/legacy_event_compat/bus_spec.rb