rspec / rspec-mocks

RSpec's 'test double' framework, with support for stubbing and mocking
https://rspec.info
MIT License
1.16k stars 356 forks source link

Document receive(:msg).with(satisfy{|arg| ... }) #1477

Closed tjallingvanderwal closed 7 months ago

tjallingvanderwal commented 2 years ago

This is the combination I've been looking for, but that has eluded me for years.

The readme and the table in the relish docs both mention that any matcher can be used, but it never occurred to me to combine with with satisfy.

I've added 2 example usages to the readme and added a Cucumber story to document this combination.

The documentation for satisfy suggest to write a custom matcher, but that feels over the top for many one-off situations.

pirj commented 7 months ago

https://github.com/cucumber/cucumber-expressions/pull/272 https://github.com/cucumber/cucumber-expressions/pull/273 for ruby-head

Something weird is wrong with 3.2, IDK

For 1.8.7 the failure diff is

+         expected: (satisfy block)
-expected: (satisfy expression `data[:a][:b][:c] == 5`)

which is due to the lack of Ripper in Ruby < 1.9.2 . I intend to clamp this feature on 1.8.7 cucumber runs.

pirj commented 7 months ago

The Ruby 3.2 rspec-core related failure reproduced in a https://github.com/rspec/rspec-core/pull/3046 build, so I intend to fix it there.

@tjallingvanderwal Thank you for this nice doc addition! Please accept my apologies for the long processing.

tjallingvanderwal commented 7 months ago

@tjallingvanderwal Thank you for this nice doc addition! Please accept my apologies for the long processing.

No apologies needed. Thank you for finishing my pull request.