Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

[httpclient] adapter doesn't mock properly requests issued via HTTPClient#get #322

Closed
miguelff opened this Issue Oct 29, 2013 · 2 comments

Comments

Projects
None yet
2 participants
Contributor

miguelff commented Oct 29, 2013

In particular, it doesn't take into account header values provided to HTTPClient and delegated to HTTPClient::SessionManager

The following example fails:

  it "provides user-agent on each request" do
    user_agent = "MyUserAgent/0.1"
    stub_request(:get, "www.example.com/user-agent").to_return do |request|
      {:body => request.headers["User-Agent"]}
    end
    client= HTTPClient.new(:agent_name => user_agent)
    res = client.get("www.example.com/user-agent")
    res.body.should == user_agent
  end

Message is:

Failures:

  1) Almodovar::ClientWrapper provides user-agent on each request
     Failure/Error: res.body.should == user_agent
       expected: "MyUserAgent/0.1"
            got: "" (using ==)
     # ./spec/unit/http_session_spec.rb:29:in `block (2 levels) in <top (required)>'
Owner

bblimke commented Oct 30, 2013

Do you know how to fix httpclient_adapter to handle these headers? I'm happy to have a look, if I find time.

Contributor

miguelff commented Oct 31, 2013

This PR fixes it, let me know your considerations.

@bblimke bblimke closed this in #325 Nov 4, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment