spec/event_spec.rb in reactor-0.9.9 vs spec/event_spec.rb in reactor-0.10.0
- old
+ new
@@ -19,11 +19,20 @@
let(:model) { ArbitraryModel.create! }
let(:event_name) { :user_did_this }
describe 'publish' do
+ let!(:uuid) { 'uuid' }
+ before { allow(SecureRandom).to receive(:uuid).and_return(uuid) }
+
+
it 'fires the first perform and sets message event_id' do
- expect(Reactor::Event).to receive(:perform_async).with(event_name, 'actor_id' => '1', 'event' => :user_did_this)
+ 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
+
+ it 'generates and assigns a UUID to the event' do
+ 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
end
describe 'perform' do