Skip to content
This repository has been archived by the owner on Nov 30, 2024. It is now read-only.

Don't use RSpec.configure to use the matcher DSL #1048

Closed
wants to merge 1 commit into from

Conversation

alyssais
Copy link
Contributor

@alyssais alyssais commented Mar 2, 2018

rspec-expectations shouldn't have knowledge of how to hook itself into rspec-core. rspec-core already includes the RSpec::Matchers module in example groups, so just including the module there (in addition to extending it) is enough to provide it to rspec-core, even if rspec-core hasn't been loaded yet and is loaded after rspec-expectations.

Fixes rspec/rspec#122.

rspec-expectations shouldn't have knowledge of how to hook itself into
rspec-core. rspec-core already includes the `RSpec::Matchers` module in
example groups, so just including the module there (in addition to
extending it) is enough to provide it to rspec-core, even if rspec-core
hasn't been loaded yet and is loaded after rspec-expectations.

Fixes https://github.com/rspec/rspec-expectations/issues/1045.
@myronmarston
Copy link
Member

As the failing build indicates, this is not quite sufficient. In rspec-core, we include RSpec::Matchers but we do not extend it (nor should we: that would add a ton of methods to a context where we do not want those methods added!).

I think the only solution here is to update rspec-core to extend RSpec::Matchers::DSL. This can be done in the config.expect_with method, as part of the branch for rspec.

Once that's been done, I think we can remove the extend call being done in rspec-expectations and everything should continue working.

@pirj
Copy link
Member

pirj commented Jan 11, 2020

Are you still up to fix this @alyssais ?

@JonRowe JonRowe changed the base branch from master to main August 2, 2020 02:05
@JonRowe
Copy link
Member

JonRowe commented Nov 30, 2024

I'm closing this due to inactivity during the monorepo migration, the issue will be transferred

@JonRowe JonRowe closed this Nov 30, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Matcher DSL isn't available inside example groups if rspec-expectations is loaded before rspec-core.
4 participants