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

webmock with http.rb 5.0 raises KeyError #940

Closed
epaew opened this issue May 13, 2021 · 1 comment · Fixed by #941
Closed

webmock with http.rb 5.0 raises KeyError #940

epaew opened this issue May 13, 2021 · 1 comment · Fixed by #941

Comments

@epaew
Copy link

epaew commented May 13, 2021

Since http.rb 5.0.0 has released with breaking change httprb/http#546, now webmock gem cannot stub the request through http.rb gem.

Environments

  • MRI 2.6.6, 2.7.1
    • http 5.0.0
    • webmock 3.12.2

Sample code to reproduce

require "http"
require "webmock"

include WebMock::API

def setup
  WebMock.enable!

  stub_request(:get, "www.google.com").to_return(status: 200, body: "body")
end

def subject
  HTTP.get("http://www.google.com")
end

setup
puts subject
 % ruby test.rb
Traceback (most recent call last):
        11: from test.rb:17:in `<main>'
        10: from test.rb:13:in `subject'
         9: from /Users/epaew/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/http-5.0.0/lib/http/chainable.rb:20:in `get'
         8: from /Users/epaew/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/http-5.0.0/lib/http/chainable.rb:75:in `request'
         7: from /Users/epaew/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/http-5.0.0/lib/http/client.rb:31:in `request'
         6: from /Users/epaew/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/webmock-3.12.2/lib/webmock/http_lib_adapters/http_rb/client.rb:8:in `perform'
         5: from /Users/epaew/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/webmock-3.12.2/lib/webmock/http_lib_adapters/http_rb/webmock.rb:10:in `exec'
         4: from /Users/epaew/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/webmock-3.12.2/lib/webmock/http_lib_adapters/http_rb/webmock.rb:41:in `replay'
         3: from /Users/epaew/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/webmock-3.12.2/lib/webmock/http_lib_adapters/http_rb/response.rb:32:in `from_webmock'
         2: from /Users/epaew/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/webmock-3.12.2/lib/webmock/http_lib_adapters/http_rb/response.rb:32:in `new'
         1: from /Users/epaew/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/http-5.0.0/lib/http/response.rb:46:in `initialize'
/Users/epaew/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/http-5.0.0/lib/http/response.rb:46:in `fetch': key not found: :request (KeyError)
horgh added a commit to horgh/webmock that referenced this issue May 13, 2021
5.0.0 had a breaking change.

Fixes bblimke#940
horgh added a commit to horgh/webmock that referenced this issue May 13, 2021
5.0.0 had a breaking change.

Fixes bblimke#940
@bblimke
Copy link
Owner

bblimke commented May 14, 2021

Fixed in version 3.13.0 thanks to @horgh PR #941

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

Successfully merging a pull request may close this issue.

2 participants