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

Turn strict_predicate_matchers on by default #1277

Merged
merged 3 commits into from
Jan 8, 2021

Conversation

pirj
Copy link
Member

@pirj pirj commented Jan 6, 2021

@pirj pirj self-assigned this Jan 6, 2021
@pirj pirj added this to the 4.0 milestone Jan 6, 2021
@pirj pirj mentioned this pull request Jan 6, 2021
53 tasks
@pirj pirj marked this pull request as draft January 7, 2021 08:45
@pirj pirj force-pushed the use-strict_predicate_matchers-by-default branch from f2e3f62 to 884410f Compare January 8, 2021 07:01
@pirj pirj requested review from JonRowe and benoittgt January 8, 2021 07:03
@pirj pirj force-pushed the use-strict_predicate_matchers-by-default branch from 98264cd to 6423e9c Compare January 8, 2021 08:49
@pirj pirj marked this pull request as ready for review January 8, 2021 08:50
around do |example|
configuration = example.metadata[:with_configuration]
key = configuration.keys.first
value = configuration.values.first
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean if you're going to extract this, you might as well detect / presume the hash and map on them...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I've added to my todo to do that, and also to rework "with warn_about_potential_false_positives" and other shared examples that flip configuration bits.
Might even be extracted to Support if it's useful in other repos.

But I decided to leave this refactoring for later, to after 4.0.

Copy link
Member

@JonRowe JonRowe Jan 8, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do it here first. Theres no point this being a hash and not used, if it doesn't later get refactored due to time constraints or other issues, this will be broken forever.

Alternatively just leave it as it was and save the whole refactoring for later.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Theres no point this being a hash and not used

I tend to agree and started implementing it this way, but it looked quite clumsy (due to the lack of Hash#slice in Ruby 2.3).
Another approach could be to use two different metadata keys, with_configuration_key and with_configuration_value, quite clumsy too.

The value passed to with_configuration could be an array and using first/last. That imposes the question of how it should behave if we would be passing an array with more than two entries.

So, until this shared example gained some critical mass of usages of it, I decided not to grow its complexity.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, until this shared example gained some critical mass of usages of it, I decided not to grow its complexity.

It currently has unnecessary complexity for its use case in the form of the dynamic methods anyway, either simplify it so its specific to the config we're changing, or complete it please :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can also rework existing usages of alternative approaches but would prefer to do this later, after #1253 is merged and after we remove include_chain_clauses_in_custom_matcher_descriptions et al to avoid unnecessary work.

around do |example|
configuration = example.metadata[:with_configuration]
key = configuration.keys.first
value = configuration.values.first
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, until this shared example gained some critical mass of usages of it, I decided not to grow its complexity.

It currently has unnecessary complexity for its use case in the form of the dynamic methods anyway, either simplify it so its specific to the config we're changing, or complete it please :)

@pirj pirj requested a review from JonRowe January 8, 2021 10:17
spec/spec_helper.rb Outdated Show resolved Hide resolved
@pirj pirj merged commit 1515f2b into 4-0-dev Jan 8, 2021
@pirj pirj deleted the use-strict_predicate_matchers-by-default branch January 8, 2021 19:02
@pirj
Copy link
Member Author

pirj commented Jan 8, 2021

cc @marcandre

@marcandre
Copy link
Contributor

Great 🎉

yujinakayama pushed a commit to yujinakayama/rspec-monorepo that referenced this pull request Oct 19, 2021
…rspec/use-strict_predicate_matchers-by-default

Turn strict_predicate_matchers on by default

---
This commit was imported from rspec/rspec-expectations@1515f2b.
tgxworld pushed a commit to discourse/discourse that referenced this pull request Jul 28, 2022
* Remove outdated option

rspec/rspec-core@0407831

* Use the non-globally exposed RSpec syntax

rspec/rspec-core#2803

* Use the non-globally exposed RSpec syntax, cont

rspec/rspec-core#2803

* Comply to strict predicate matchers

See:
 - rspec/rspec-expectations#1195
 - rspec/rspec-expectations#1196
 - rspec/rspec-expectations#1277
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

Successfully merging this pull request may close these issues.

3 participants