-
-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve implicit description for RSpec::Rails::Matchers::ActionCable::HaveBroadcastedTo #2795
Improve implicit description for RSpec::Rails::Matchers::ActionCable::HaveBroadcastedTo #2795
Conversation
622523a
to
045fe57
Compare
spec/rspec/rails/matchers/action_cable/have_broadcasted_to_spec.rb
Outdated
Show resolved
Hide resolved
spec/rspec/rails/matchers/action_cable/have_broadcasted_to_spec.rb
Outdated
Show resolved
Hide resolved
spec/rspec/rails/matchers/action_cable/have_broadcasted_to_spec.rb
Outdated
Show resolved
Hide resolved
spec/rspec/rails/matchers/action_cable/have_broadcasted_to_spec.rb
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good improvements here, just some minor tweaks to the specs and a removal of a private api in favour of the public one
spec/rspec/rails/matchers/action_cable/have_broadcasted_to_spec.rb
Outdated
Show resolved
Hide resolved
spec/rspec/rails/matchers/action_cable/have_broadcasted_to_spec.rb
Outdated
Show resolved
Hide resolved
spec/rspec/rails/matchers/action_cable/have_broadcasted_to_spec.rb
Outdated
Show resolved
Hide resolved
spec/rspec/rails/matchers/action_cable/have_broadcasted_to_spec.rb
Outdated
Show resolved
Hide resolved
spec/rspec/rails/matchers/action_cable/have_broadcasted_to_spec.rb
Outdated
Show resolved
Hide resolved
spec/rspec/rails/matchers/action_cable/have_broadcasted_to_spec.rb
Outdated
Show resolved
Hide resolved
02b8639
to
7ca8249
Compare
Thank you both for your speedy reviews! I think I've addressed everything you've mentioned 👍 |
@@ -151,7 +160,7 @@ def data_description(data) | |||
if data.is_a?(RSpec::Matchers::Composable) | |||
data.description | |||
else | |||
data | |||
data.inspect |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What did this actually come from, I'm on the fence wether letting user values user to_s
is fine or not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would expect a matcher to use this if mentioning an object. The default description for the eq
matcher does this:
it { expect("foo").to eq("foo") }
Resultant description:
is expected to eq "foo"
This adds some clarity to what the object is in context.
spec/rspec/rails/matchers/action_cable/have_broadcasted_to_spec.rb
Outdated
Show resolved
Hide resolved
…:HaveBroadcastedTo Previously, tests defined like this: ```rb it do expect { some_action }.to have_broadcasted_to("stream_name").from_channel(SomeChannel).with("some_data") end ``` would implicitly be given the description `have broadcasted to`, which is derived from the name of the matcher method. This didn't carry any extra information about the data we're expecting to be broadcast from the channel - behaviour which would be very welcome in combination with Turbo Streams. With a matcher for Turbo Streams, we might benefit from a description like "broadcast exactly 1 messages to stream with turbo-stream[action="append"][target="some_list"]". Co-authored-by: Jon Rowe <hello@jonrowe.co.uk> Co-authored-by: Phil Pirozhkov <pirj@users.noreply.github.com>
7ca8249
to
86db479
Compare
spec/rspec/rails/matchers/action_cable/have_broadcasted_to_spec.rb
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM thank you for this
Previously, tests defined like this:
would implicitly be given the description
have broadcasted to
, which is derived from the name of the matcher method.This didn't carry any extra information about the data we're expecting to be broadcast from the channel - behaviour
which would be very welcome in combination with Turbo Streams. With a matcher for Turbo Streams, we might benefit from
a description like
"broadcast exactly 1 messages to stream with turbo-stream[action="append"][target="some_list"]"
.