rspec-rails: "expect to receive with" throws error when switching to Rails 7.1
What Ruby, Rails and RSpec versions are you using?
Ruby version: 3.2.1 Rails version: 7.1.1 RSpec version: 3.12 (rspec-rails 6.0.3)
Observed behaviour
Example spec expect(Worker).to receive(:perform_async).with(param1, param2)
returns ArgumentError: wrong number of arguments (given 2, expected 0)
Switching to deprecated Worker.should_receive(:perform_async).with(param1, param2) passes.
Expected behaviour
Passes with “expect to receive with” syntax.
Can you provide an example app?
About this issue
- Original URL
- State: closed
- Created 9 months ago
- Comments: 17 (5 by maintainers)
Regarding the initial issue, I am getting the same for every
within my specs after upgrading to Rails 7.1:According to ActiveSupport’s changelog,
Object#withwas added with 7.1.0.beta1:Relevant commit: https://github.com/rails/rails/commit/1884323574b35b3a2286850f3c98f677633728f1
@JonRowe can confirm, 3.12.6 solves the issue, we were still on 3.12.3 👍