Sha256: 0a2f22ac0aa16059841b86021d4b3e1c7e4780f991e2c2bb7d689ee823aea7f0

Contents?: true

Size: 968 Bytes

Versions: 5

Compression:

Stored size: 968 Bytes

Contents

require 'spec_helper'

Reactor.in_test_mode do
  class SomeClass
    include Reactor::Subscribable
    on_event :test_event, -> (event) { self.spy_on_me }
  end
end

describe Reactor do
  let(:subscriber) { SomeClass }

  describe '.test_mode!' do
    it 'sets Reactor into test mode' do
      expect(Reactor.test_mode?).to be_falsey
      Reactor.test_mode!
      expect(Reactor.test_mode?).to be_truthy
    end
  end

  context 'in test mode' do
    before { Reactor.test_mode! }
    after  { Reactor.disable_test_mode! }

    it 'subscribers created in test mode are disabled' do
      expect(subscriber).not_to receive :spy_on_me
      Reactor::Event.publish :test_event
    end

    describe '.with_subscriber_enabled' do
      it 'enables a subscriber during test mode' do
        expect(subscriber).to receive :spy_on_me
        Reactor.with_subscriber_enabled(subscriber) do
          Reactor::Event.publish :test_event
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
reactor-0.12.1 spec/reactor_spec.rb
reactor-0.11.4 spec/reactor_spec.rb
reactor-0.11.2 spec/reactor_spec.rb
reactor-0.11.1 spec/reactor_spec.rb
reactor-0.11.0 spec/reactor_spec.rb