-
-
Notifications
You must be signed in to change notification settings - Fork 395
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
Matcher DSL isn't available inside example groups if rspec-expectations is loaded before rspec-core. #1045
Comments
This generally shouldn't be an issue, after all the first thing |
I have no idea what WFYT stands for... Anyhow, IMO it's an anti pattern that |
WFYT was WDYT typo'd :)
Yep I agree |
Will see if I have time at the weekend :) |
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#1045.
Not sure if this is the right place to report this, but it seemed the most sensible.
The rspec-expectations matcher DSL checks at load time whether
RSpec.configuration
is defined, and only includes itself if it is:rspec-expectations/lib/rspec/matchers/dsl.rb
Line 97 in a81b067
This causes problems if, e.g., you have a Gemfile like this:
When rspec-collection_matchers is loaded, it loads rspec-expectations, but rspec-core has not yet been loaded. This means that the matcher DSL will not be available in example groups, and so scoped aliased and negated matchers cannot be used without manually extending
RSpec::Matchers::DSL
.The text was updated successfully, but these errors were encountered: