-
-
Notifications
You must be signed in to change notification settings - Fork 43
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
Enhance AssertMatch
/RefuteMatch
to check match?
and =~
methods
#240
Enhance AssertMatch
/RefuteMatch
to check match?
and =~
methods
#240
Conversation
@@ -24,7 +24,8 @@ module MinitestCopRule | |||
# @api private | |||
# | |||
def define_rule(assertion_method, target_method:, preferred_method: nil, inverse: false) | |||
preferred_method = "#{assertion_method}_#{target_method.to_s.delete('?')}" if preferred_method.nil? | |||
target_methods = Array(target_method) | |||
preferred_method = "#{assertion_method}_#{target_methods.first.to_s.delete('?')}" if preferred_method.nil? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It may be confusing to see the special treatment of the first element. So, the order of the array shouldn't matter for API user.
Perhaps it would be preferable to require preferred_method
optional param if more than one element is specified. It might be helpful to add it to the documentation and throw an exception message if it was not specified the option.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Added a check and updated the docs.
7a7dde6
to
33c35e8
Compare
preferred_method = "#{assertion_method}_#{target_method.to_s.delete('?')}" if preferred_method.nil? | ||
target_methods = Array(target_method) | ||
if target_methods.size > 1 && preferred_method.nil? | ||
raise ArgumentError, 'preferred_method should be provided if using more than one target methods' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you tweak it?
raise ArgumentError, 'preferred_method should be provided if using more than one target methods' | |
raise ArgumentError, '`:preferred_method` keyword argument must be used if using more than one target methods.' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
33c35e8
to
d871dcd
Compare
Thanks! |
Closes #239.