Skip to content

Disable negated matcher for RSpec#796

Open
coorasse wants to merge 1 commit intodevelopfrom
disallow_negeted_matcher_with_multiple_subjects
Open

Disable negated matcher for RSpec#796
coorasse wants to merge 1 commit intodevelopfrom
disallow_negeted_matcher_with_multiple_subjects

Conversation

@coorasse
Copy link
Member

@coorasse coorasse commented Jul 6, 2022

Let's not allow to specify expect(...).not_to be_able_to(:action_a, :action_b) for multiple actions. This lead in the past to too many open issues. Here are some:

Here is a recap: Marc is allowed to eat apples but not bananas.

can :collect, 🍎 
cannot :eat, 🍎 

expect(mark).to be_able to(:collect, 🍎 )
expect(mark).not_to be_able to(:eat, 🍎 )

# this below will fail, because Mark cannot eat 🍎 
expect(mark).to be_able to([:eat, :collect], 🍎 ) 

# this below will pass, because is exactly the opposite of the one above.
expect(mark).not_to be_able to([:eat, :collect], 🍎 ) 

but a reader might say "I expect Mark to not be able to eat the 🍎 !", why is he able to? This caused quite some confusion and nasty bugs. From now on you have to split the one above into:

expect(mark).to be_able to(:collect, 🍎 ) 
expect(mark).not_to be_able to(:eat, 🍎 ) 

@coorasse coorasse force-pushed the disallow_negeted_matcher_with_multiple_subjects branch from e3d28fd to e4badf3 Compare July 6, 2022 12:36
@coorasse coorasse force-pushed the disallow_negeted_matcher_with_multiple_subjects branch from e4badf3 to 1d1c8fe Compare July 6, 2022 13:57
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.

1 participant