Skip to content
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

Adding values_match? in have_broadcasted_to checker to accept anything as a hash value when data is provided #2684

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -112,7 +112,7 @@ def check(messages)
decoded = ActiveSupport::JSON.decode(msg)
decoded = decoded.with_indifferent_access if decoded.is_a?(Hash)

if @data.nil? || @data === decoded
if @data.nil? || values_match?(@data, decoded)
@block.call(decoded)
true
else
Expand Down
Expand Up @@ -170,6 +170,12 @@ def broadcast(stream, msg)
}.to have_broadcasted_to('stream').with(a_hash_including(name: "David", id: 42))
end

it "passes with provided data matchers with anything" do
expect {
broadcast('stream', id: 42, name: "David", message_id: 123)
}.to have_broadcasted_to('stream').with({ name: anything, id: anything, message_id: anything })
end

it "generates failure message when data not match" do
expect {
expect {
Expand Down