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

be_successful on a request spec hangs #2592

Open
jcoyne opened this issue Apr 12, 2022 · 2 comments
Open

be_successful on a request spec hangs #2592

jcoyne opened this issue Apr 12, 2022 · 2 comments

Comments

@jcoyne
Copy link

jcoyne commented Apr 12, 2022

I'm seeing behavior where using be_successful hangs (rather than fails) when the request status is not a 200.

hangs:

      get "/items/#{id}"
      expect(response).to be_successful

Fails right away:

      get "/items/#{id}"
      expect(response).to have_http_status(:ok)

with:

     Failure/Error: expect(response).to have_http_status(:ok)
       expected the response to have status code :ok (200) but it was :forbidden (403)

Using:

    rspec-rails (5.1.1)
    rspec-core (3.11.0)
    rails (7.0.2.3)
@pirj
Copy link
Member

pirj commented Apr 12, 2022

Shouldn't it be expect(response).to be_ok?

Would expect(response.successful?).to be true hang, too?

@jcoyne
Copy link
Author

jcoyne commented Apr 12, 2022

@pirj I think that be_successful is true for any 2xx based response. (e.g. :ok, :created, :no_content)

When I use expect(response.successful?).to be true it fails right away as expected.

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

2 participants