rspec / rspec-mocks

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

(Fixed in `3.13.0pre`) `ActiveSupport`'s `Object#with` core extension overrides `RSpec::Mocks::Matchers::Receive(Object)#with` #1559

Closed boardfish closed 10 months ago

boardfish commented 10 months ago

Didn't find this issue recorded as I found it, but I'd receive test failures like this:

allow(something).to receive(:a_method).with(/something/, anything)

     ArgumentError:
       wrong number of arguments (given 2, expected 0)

This struck me as weird because with should receive any number of args. Using byebug to check the source and source_location of the with method, I found that it had been overridden by ActiveSupport. Updating my Gemfile to use the main branch as recommended on another issue fixed this:

  %w[rspec-core rspec-expectations rspec-mocks rspec-rails rspec-support].each do |lib|
    gem lib, git: "https://github.com/rspec/#{lib}.git", branch: 'main'
  end
JonRowe commented 10 months ago

Yes there is an unreleased workaround for the clash with Rails