Skip to content
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

RSpec/Rails/HttpStatus works partially with last_response #20

Open
ericproulx opened this issue Apr 7, 2024 · 0 comments
Open

RSpec/Rails/HttpStatus works partially with last_response #20

ericproulx opened this issue Apr 7, 2024 · 0 comments

Comments

@ericproulx
Copy link

ericproulx commented Apr 7, 2024

last_response addition doesn't work with the have_http_status matcher since it's a Rails/Matcher that acts on ActionDispatch::TestResponse

Although, I think enforcing the style be_status should describe an offense like

RSpecRails/HaveHttpStatus: Prefer expect(last_response).to be_successful over expect(last_response.status).to eq(200)

instead of

RSpecRails/HaveHttpStatus: Prefer expect(last_response).to have_http_status(200) over expect(last_response.status).to eq(200).

I don't know if there's a way to implicitely enforce be_*** style when last_reponse is found. I'm not that familiar with AST.
Maybe it could be its own cop but outside of Rails.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant