-
-
Notifications
You must be signed in to change notification settings - Fork 276
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
double/instance_double argument type #1136
Comments
|
I can also add that changing from a class literal to a string/symbol arguably makes the cop unsafe unless |
We have a very simple Rubocop rule that autocorrects from string to Class for |
That will be very kind of you, @corsonknowles ! A pr is welcome. |
Happy to help! Here's a draft PR: We've run this on over 25,000 files and had it in place for a few years. I'm running into a little hiccup with the rake task for documentation (but the ardocs did successfully generate) |
Addresses rubocop#1136 Adds a cop which can autocorrect from String declarations for instance_double to Class declarations. Symbol declarations are not affected.
Addresses rubocop#1136 Adds a cop which can autocorrect from String declarations for instance_double to Class declarations. Symbol declarations are not affected.
Addresses rubocop#1136 Adds a cop which can autocorrect from String declarations for instance_double to Class declarations. Symbol declarations are not affected.
Addresses rubocop#1136 Adds a cop which can autocorrect from String declarations for instance_double to Class declarations. Symbol declarations are not affected.
Addresses rubocop#1136 Adds a cop which can autocorrect from String declarations for instance_double to Class declarations. Symbol declarations are not affected.
Addresses rubocop#1136 Adds a cop which can autocorrect from String declarations for instance_double to Class declarations. Symbol declarations are not affected.
Addresses rubocop#1136 Adds a cop which can autocorrect from String declarations for instance_double to Class declarations. Symbol declarations are not affected.
Addresses rubocop#1136 Adds a cop which can autocorrect from String declarations for instance_double to Class declarations. Symbol declarations are not affected.
It looks like we can close this issue due to:
Discussion here about how to reconcile the two RSpec cops: Thanks to @lucthev for reporting this. |
Thank you! |
I'm seeing double/instance_double/class_double/object_double/spy etc. being called with sometimes a string, sometimes a symbol (perhaps because the rspec-mocks documentation explicitly allows both), and of course sometimes a constant referring to a class or module.
I think mixing string and symbol arguments is a bit of a mess, so I would propose making a new cop that enforces either one or the other – with strings being the default enforced style. Why? Because
"MyClass"
looks better than:MyClass
in those cases where you pass in a module name as a string/symbol.The text was updated successfully, but these errors were encountered: