spec/event_spec.rb in reactor-2.0.0 vs spec/event_spec.rb in reactor-2.0.1
- old
+ new
@@ -61,22 +61,43 @@
expect(Reactor::Event).to receive(:perform_async).with(event_name, 'actor_id' => '1', 'event' => :user_did_this, 'uuid' => uuid)
Reactor::Event.publish(:user_did_this, actor_id: '1')
end
context 'when in a production rails console' do
- it 'requires a second argument srsly: true' do
+ before do
stub_const('Rails::Console', Class.new)
ENV['RACK_ENV'] = 'production'
+ end
- expect {
- Reactor::Event.publish(:thing)
- }.to raise_exception(ArgumentError)
+ after do
+ ENV['RACK_ENV'] = 'development'
+ end
- expect {
- Reactor::Event.publish(:thing, srsly: true)
- }.to_not raise_exception
+ context 'when allowing console usage' do
+ before { ENV['REACTOR_CONSOLE_ENABLED'] = 'true' }
+ after { ENV['REACTOR_CONSOLE_ENABLED'] = nil }
- ENV['RACK_ENV'] = 'development'
+ it 'does not require `srsly: true`' do
+ expect {
+ Reactor::Event.publish(:thing)
+ }.to_not raise_exception
+
+ expect {
+ Reactor::Event.publish(:thing, srsly: true)
+ }.to_not raise_exception
+ end
+ end
+
+ context 'without specifying console usage' do
+ it 'requires a second argument srsly: true' do
+ expect {
+ Reactor::Event.publish(:thing)
+ }.to raise_exception(ArgumentError)
+
+ expect {
+ Reactor::Event.publish(:thing, srsly: true)
+ }.to_not raise_exception
+ end
end
end
describe 'using injected validator block' do
before { Reactor.validator -> (_event) {raise 'InvalidEvent'} }