spec/reactor_spec.rb in reactor-0.12.1 vs spec/reactor_spec.rb in reactor-0.12.2
- old
+ new
@@ -32,8 +32,26 @@
expect(subscriber).to receive :spy_on_me
Reactor.with_subscriber_enabled(subscriber) do
Reactor::Event.publish :test_event
end
end
+
+ it 'disables the subscriber outside the block' do
+ expect(Reactor::TEST_MODE_SUBSCRIBERS).to be_empty
+ Reactor.with_subscriber_enabled(subscriber) do
+ expect(Reactor::TEST_MODE_SUBSCRIBERS).to contain_exactly(subscriber)
+ end
+ expect(Reactor::TEST_MODE_SUBSCRIBERS).to be_empty
+ end
+
+ it 'correctly handles exceptions inside the block' do
+ expect(Reactor::TEST_MODE_SUBSCRIBERS).to be_empty
+ expect {
+ Reactor.with_subscriber_enabled(subscriber) do
+ raise RuntimeError
+ end
+ }.to raise_error(RuntimeError)
+ expect(Reactor::TEST_MODE_SUBSCRIBERS).to be_empty
+ end
end
end
end