Skip to content

RSpec/Rails/HttpStatus works partially with last_response #20

@ericproulx

Description

@ericproulx

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions