pubsub_on_rails icon indicating copy to clipboard operation
pubsub_on_rails copied to clipboard

Emitter test from README not working properly

Open ikowasz opened this issue 2 years ago • 0 comments

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.

ikowasz avatar Jun 20 '22 08:06 ikowasz