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

Custom Matcher Used via alias_matcher Conflicts With ActiveSupport's Object#with #1437

Closed
sshaw opened this issue Nov 15, 2023 · 5 comments
Closed

Comments

@sshaw
Copy link

sshaw commented Nov 15, 2023

Subject of the issue

Rails 7.1 added Object#with which can conflict with custom matchers that define a #with method (chain :with) when used via an alias_matcher

Your environment

  • Ruby version: 3.1.3
  • rspec-expectations version: 3.12.3

Steps to reproduce

RSpec::Matchers.define :foo do
  match do |n|
    true
  end

  chain :with do |n|
  end
end

RSpec::Matchers.alias_matcher :bar, :foo

expect(1).to foo(1).with(2)
expect(1).to bar(1).with(2)

Expected behavior

Neither assertion should raise an ArgumentError

Actual behavior

The call to the aliased matcher (bar)'s with results in an argument error as the #with that is called is ActiveSupport's Object#with no the custom matchers

@JonRowe
Copy link
Member

JonRowe commented Nov 16, 2023

Can you try main?

@sshaw
Copy link
Author

sshaw commented Nov 20, 2023

Can you try main?

@JonRowe can't install it (with relative ease). Get various 3.13.0.pre version not found.

gem 'rspec-expectations', :github => "rspec/rspec-expectations", :branch => "main"

Gives me:

Could not find compatible versions\n\nBecause every version of rspec-expectations depends on rspec-support = 3.13.0.pre\n  and rspec-support = 3.13.0.pre could not be found in rubygems repository https://rubygems.org/ or installed locally,
gem 'rspec', :github => "rspec/rspec", :branch => "main"

Gives me similar error

@JonRowe
Copy link
Member

JonRowe commented Nov 21, 2023

%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

@sshaw
Copy link
Author

sshaw commented Nov 22, 2023

Thanks @JonRowe, looks to be working under 3.13.0.pre 💪

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

No branches or pull requests

3 participants