-
-
Notifications
You must be signed in to change notification settings - Fork 1k
[DOCUMENTATION] Are controller specs discouraged in favor of request specs? #1838
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
Comments
Yes. The best advice we can give for people working on rails apps is to write request specs instead of controller specs. I'd consider writing a new controller spec in 2017 to be a smell, even on an older rails app. Keeping controller specs around for legacy reasons is absolutely fine though. @rlue if you'd like to open a PR on the readme I think that's a reasonable thing to do. |
Thanks, PR submitted! If you could entertain a tangent — I’m having trouble grokking the terminology of test vs. spec, and wasn’t sure how to label the relationship between “request specs” and “integration tests”. Would it be accurate to say that a specification is a description of an application’s desired behavior (as opposed to the definition of an application’s actual behavior; i.e., the app code itself), and that specs define the parameters of the test? That is, can I say that request specs are “for” integration tests? |
honestly I kind of use the two interchangeably :/ |
Honestly.. I don't need to test the whole stack/rack/middleware most of the time. I would favour faster tests over completeness. I use factories and moc's for the same reason. |
Request specs are only marginally slower than controller specs, you are testing a large part of the middleware stack in controller specs too (they have never been unit tests) (request specs are not end to end, those are facilitated by system test/specs these days). Regardless |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
I suggest moving this discussion to our mailing list, or even better to Rails discussions. |
I stumbled across a guide on everydayrails.com today that made the following claim:
The RSpec 3.5 release notes (where the author presumably got this information) had this to say (emphasis mine):
and
So it sounds like controller specs are discouraged, but not deprecated (in adherence to SEMVER)? If this is the case, perhaps it would be helpful to add a note to this effect in the README of this repo (specifically, the “Controller Specs” section)?
If the maintainers are okay with this idea, I'd be happy to submit a PR.
The text was updated successfully, but these errors were encountered: