Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

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

Closed
miguelff opened this Issue · 2 comments

2 participants

Miguel Fernández Bartosz Blimke
Miguel Fernández

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)>'
Bartosz Blimke
Owner

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

Miguel Fernández

This PR fixes it, let me know your considerations.

Bartosz Blimke bblimke closed this in #325
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.