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

stubbed HTTParty request's response is nil #522

Closed
maxjacobson opened this issue Sep 14, 2015 · 3 comments
Closed

stubbed HTTParty request's response is nil #522

maxjacobson opened this issue Sep 14, 2015 · 3 comments

Comments

@maxjacobson
Copy link

I think this may be a bug. Here's a failing test to demonstrate the behavior: master...maxjacobson:stubbed-request-is-nil

@davidbegin
Copy link
Collaborator

This is because you did not specify a body to be returned, If you did your test would pass.

Like this:

describe 'HTTParty' do
  it "doesn't return nil" do
    req = stub_request(:post, 'http://example.com').to_return(status: 201, body: "response body")
    resp = HTTParty.post('http://example.com')
    expect(resp.success?).to be true

    expect(resp).to_not be_nil
  end
end

Does that help?

@maxjacobson
Copy link
Author

@presidentJFK

aha! that does help, thanks

It's still a little unexpected but... I can work with that 😄

@davidbegin
Copy link
Collaborator

No prob. I'll look into updating the readme to make this more clear.

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