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

Conversation

TimoPeraza
Copy link
Contributor

@TimoPeraza TimoPeraza commented Jun 22, 2023

Yesterday, while I was working on my project, when I was doing a test, I wanted to do something like

let(:data) do
  { hash_key: anything }
end

it 'my test' do
  expect {
    some_process
  }.to have_broadcasted_to(object).from_channel(channel).with(data)
end

And I got the error:

Expected to broadcast exactly 1 messages to channel: with {"hash_key"=>#<RSpec::Mocks::ArgumentMatchers::AnyArgMatcher:0x000000011d833ee8> }, but broadcast 0
       Broadcasted messages to channel:
          {"hash_key": hash_value }

After doing some research with a partner we saw that the check method use === instead of using Support::FuzzyMatcher.values_match? as most of the checks in rspec. For example when we use receive().with() rspec uses the second one.

The idea of this PR is just to change it to support the same behavior.

@TimoPeraza TimoPeraza force-pushed the fix-have-broadcasted-to-anything-matcher branch from 39ae8de to 07b3e33 Compare June 22, 2023 17:37
@benoittgt
Copy link
Member

Thanks for the PR. For me this is good, but I prefer to wait for another approval.

@JonRowe JonRowe merged commit b7dd8b7 into rspec:main Jun 23, 2023
15 checks passed
JonRowe added a commit that referenced this pull request Jun 23, 2023
JonRowe added a commit that referenced this pull request Oct 31, 2023
…hing-matcher

Adding values_match? in have_broadcasted_to checker to accept anything as a hash value when data is provided
JonRowe added a commit that referenced this pull request Oct 31, 2023
@JonRowe
Copy link
Member

JonRowe commented Nov 21, 2023

Released in 6.0.4 / 6.1.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants