-
-
Notifications
You must be signed in to change notification settings - Fork 116
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
Update and discourage use of controller specs #113
Comments
Absolutely. The guide is behind the reality in this regard. There's a mention of request specs here https://github.com/rubocop-hq/rspec-style-guide/#rails-integration, but the problem with slow request specs is long gone. I'm against of keeping controller spec guidelines and recommending request specs over controller specs at the same time. It's time for the change. Would you like to take a stab at it? Useful resources:
|
For reference, it was Rails 5 when controller tests were deprecated: https://blog.bigbinary.com/2016/04/19/changes-to-test-controllers-in-rails-5.html |
Also this rails/rails#22496 |
I think this is an overstatement leading to current misunderstandings. From the blog post you linked:
From the original issue: rails/rails#22076
So controller tests are still around. It's just not testing which templates are rendered and which instance variables are set. |
Agree, functional controller tests (that map to RSpec Rails' Controller specs) are said to use This needs to be fixed in RSpec Rails' docs and reflected in the guideline as well. "Removed |
So wait a second, either there is some massive hair splitting going on or all this controller vs request specs thing is based on misunderstandings. What is supposed to be the difference between controller tests and integration tests in a rails non-rspec test suite? They both are using the same class |
Nice find, @klyonrad! So, from the Rails Guidelines on Functional Tests (RSpec's Controller Specs):
and for Integration Tests (RSpec's request specs):
So, if I understand this correctly, those tests have the same capabilities, but they are intended to test different things in different ways.
Those two types of specs have access to the same matchers (apart from deprecated From my point of view, the difference is subtle, and there's no reason not to use request specs to check cookies, headers, response status code, redirects etc. |
The guide still has a section for controller specs. I think it should be mentioned that they have been deprecated and discouraged since Rails 3 (or was it 4?). I reckon the guidelines can probably stay for legacy stuff, but a suggestion mentioning request specs might be a good idea.
The text was updated successfully, but these errors were encountered: