Skip to content

Commit

Permalink
Merge pull request #2684 from TimoPeraza/fix-have-broadcasted-to-anyt…
Browse files Browse the repository at this point in the history
…hing-matcher

Adding values_match? in have_broadcasted_to checker to accept anything as a hash value when data is provided
  • Loading branch information
JonRowe committed Jun 23, 2023
2 parents ce4b526 + 07b3e33 commit b7dd8b7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
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

0 comments on commit b7dd8b7

Please sign in to comment.