-
Notifications
You must be signed in to change notification settings - Fork 217
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
e2e tests: additional checks for application/json response headers #2609
Conversation
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.
Could we refactor the response assertions to keep it maintainable?
Almost every request will have application/json content-type, except for a handful.
Yes - a little. But it would be better if the response content type were checked automatically, so there doesn't need to be this assertion in every single test case. It could be tested when parsing the response (i.e. only decode as json if that's the content-type), or as part of the http status code check. |
Ok, gotcha. Currently it is like this: expect(response).to have_http 201
expect(response).to have_expected_headers which I could change to something like: expect(response).to be_correct 201 where I could check both assertions, with additional logic that when response code is I guess the pros is that it is more concise, cons that two assertions combined in one... which is sort of anti-pattern I suppose. 🤔 |
0b81607
to
27df4ce
Compare
Done in 27df4ce. |
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.
👍
27df4ce
to
1373e14
Compare
I don't think it's an anti-pattern. I think it's better to explicitly test more high level things. |
bors r+ |
Build succeeded: |
Issue Number
ADP-853
Overview
'content-type' => ['application/json;charset=utf-8']
headerComments
Only
204
reponses do not return'content-type' => ['application/json;charset=utf-8']
header. I assume that it is OK, since204
returns no content?I've temporarily cherry-picked c832eb5 from #2608, to be able to run all tests.