Closed jasonfb closed 3 years ago
it seems like assert_nothing_raised
is inside of Minitest but I can't seem to access those inside of my Rspec suite can I? forgive me if missed something here.
AFAICS, the error comes from Rails itself: /Users/jason/.rvm/gems/ruby-2.6.3/gems/actioncable-6.1.1/lib/action_cable/test_helper.rb:48
action-cable-testing
is meant for Rails < 6 and RSpec < 4; since you use Rails 6.1 and RSpec 4, you're using their implementations.
Try removing the gem, and if the error persists, please, submit an issue to Rails.
I think perhaps you misunderstand that for Rails 6.0 + Rails 6.1 however WITH Rspec, I think it turns out the gem is still actually live & a dependency.
my problem is indeed that I was accessing it the wrong way… https://relishapp.com/palkan/action-cable-testing/docs
For my Rails 6.1 app, when I included the gem and also add the require to the rails_helper.rb
only then do I have access to have_broadcasted_to
as expected
you're right my implementation above is wrong (obvs)
WORKS:
data = {
type: "SETUP",
to: "1",
from: "2",
sdp: "S",
candida: "1"
}
expect { post :create, params: {
room_id: room.id,
call: data
} }.to have_broadcasted_to("room:#{room.to_gid_param}").with(data)
• do include the Gem
• also add require "action_cable/testing/rspec"
to rails_helper.rb
my spec:
my code:
All I really need to do is assert that RoomChannel receives the broadcast message to the
@room
. I was going to do it with the old-styleallow_any_instance_of(X).to receive(:___)
but people recommend against this.Also I tried doing it with double (which seems unnecessary), so simple built-in assertions would be great
I'm not sure why this bug is coming from
assert_nothing_raised
inside of# /Users/jason/.rvm/gems/ruby-2.6.3/gems/actioncable-6.1.1/lib/action_cable/test_helper.rb:48:in
seems odd to me.but if this gem is in Rails anyway now may I should report directly to Rails. I'm not 100% sure what I'm looking at or if if I've done something wrong above but it seems like this should work.