pubsub_on_rails
pubsub_on_rails copied to clipboard
Emitter test from README not working properly
Hello there!
It seems that there is a mistake in testing publishers part of readme.
Using .to broadcast
with just the event name works perfectly, but declaring any arguments results in missing event_uid error.
Example:
it 'emits vessels__comment_created' do
user = create :user
vessel = create :vessel
expect {
VesselComment.create!(user: user, vessel: vessel, message: 'New comment')
}.to broadcast(:vessels__comment_created, comment_id: fetch_next_id_for(VesselComment))
end
error:
expected publisher to broadcast vessels__comment_created event with args: [{:comment_id=>14}] (actual events broadcast: vessels__comment_created({:comment_id=>14, :event_uid=>"7ad49ddea66b5805-ORIGIN-39c2bf7c9bcfc428"}))
Diff:
@@ -1 +1 @@
-[[{:comment_id=>14}]]
+[[{:comment_id=>14, :event_uid=>"7ad49ddea66b5805-ORIGIN-39c2bf7c9bcfc428"}]]
It's worth noting that adding event_uid: anything
to the broadcast's matcher parameters fixes the issue.