-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Laila Winner
committed
Nov 23, 2015
1 parent
3e2c9db
commit c7eb113
Showing
1 changed file
with
2 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
c7eb113
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.
@malandrina Thanks for making the wording more descriptive based on the discussion here. There's just one more thing on the top of my mind currently based on the above guideline, I was wondering why there isn't a mention of writing controller specs for the API end points that would check for things like the returned HTTP status codes. I'm assuming these wouldn't be tested as part of feature specs and I'm not quite sure on whether they're tested in request specs. Is it supposed to be considered implicitly that one needs to write controller specs in addition to what's mentioned in the above guideline? . Please feel free to correct me if I'm missing something here.
c7eb113
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.
@boddhisattva, good question. Request specs usually include assertions about HTTP status codes, per this example.
You’re correct that feature specs aren’t meant to include assertions about the HTTP status codes returned by API endpoints. The thinking behind this guideline is that if the JSON API is consumed by a web client that ships with the provider of the API (aka an in-app JavaScript client), it’s more beneficial to exercise our API endpoints in feature specs than controller specs.
In this scenario the HTTP status codes can be viewed as part of the underlying implementation of the behavior we want our users to experience when they use our application. Since we care more about the behavior than the underlying implementation, we can achieve a higher level of confidence in our application by exercising our API endpoints in feature specs. And since our JSON API isn’t available to clients other than the one we maintain, we don’t need to worry as much about the HTTP status codes returned by our API as we would if it were public.
It’s worth noting that this is just a guideline, though. There are, of course, exceptions to this overall strategy — there are cases where it makes sense to opt to write a controller spec instead of a feature spec for a given API endpoint.
Hope that helps illustrate the thinking behind this guideline!