webmock
webmock copied to clipboard
undefined method "write"
Hello,
Just FYI, i have this error message when i run rspec
(byebug) fill_in "Password", with: "12345678"
*** NoMethodError Exception: undefined method `write' for #<StubSocket:0x00007fa21298ab28 @closed=true>
webmock's version 3.18.0
Downgraded to 3.17.1
solve the issue
@zsan thank you for reporting.
Are you able to provide an example code to reproduce it or show more stacktrace to understand where this write
is called?
Would you mind trying the following two commits and see if it works on any of them?
gem 'webmock', github: 'bblimke/webmock', branch: '102dd56' gem 'webmock', github: 'bblimke/webmock', branch: '2c10bd9'
@rzane any thoughts?
I can confirm that 2c10bd9 is the offending commit.
Installing 102dd56 and our test suite runs just fine!
I have released 3.18.1 with reverted https://github.com/bblimke/webmock/commit/2c10bd99234c0e10718f4c27e0edb7f4c8c53057
It would be good to get a test or sample code to reproduce the issue or at least a stacktrace from the error.
@bblimke , I have a test branch that started failing with 3.18.0: https://github.com/MothOnMars/search-gov/tree/webmock
https://app.circleci.com/pipelines/github/MothOnMars/search-gov/2333/workflows/e2a6416b-7564-4a5b-8ed0-15bb64382a8b
Sample stacktrace:
Traceback (most recent call last):
14: from /home/circleci/search-gov/vendor/bundle/ruby/2.7.0/gems/capybara-3.37.1/lib/capybara/selenium/driver.rb:516:in `block in setup_exit_handler'
13: from /home/circleci/search-gov/vendor/bundle/ruby/2.7.0/gems/capybara-3.37.1/lib/capybara/selenium/driver.rb:293:in `quit'
12: from /home/circleci/search-gov/vendor/bundle/ruby/2.7.0/gems/selenium-webdriver-4.4.0/lib/selenium/webdriver/common/driver.rb:181:in `quit'
11: from /home/circleci/search-gov/vendor/bundle/ruby/2.7.0/gems/selenium-webdriver-4.4.0/lib/selenium/webdriver/remote/bridge.rb:186:in `quit'
10: from /home/circleci/search-gov/vendor/bundle/ruby/2.7.0/gems/selenium-webdriver-4.4.0/lib/selenium/webdriver/remote/bridge.rb:625:in `execute'
9: from /home/circleci/search-gov/vendor/bundle/ruby/2.7.0/gems/selenium-webdriver-4.4.0/lib/selenium/webdriver/remote/http/common.rb:59:in `call'
8: from /home/circleci/search-gov/vendor/bundle/ruby/2.7.0/gems/selenium-webdriver-4.4.0/lib/selenium/webdriver/remote/http/default.rb:77:in `request'
7: from /home/circleci/search-gov/vendor/bundle/ruby/2.7.0/gems/selenium-webdriver-4.4.0/lib/selenium/webdriver/remote/http/default.rb:118:in `response_for'
6: from /home/circleci/search-gov/vendor/bundle/ruby/2.7.0/gems/webmock-3.18.0/lib/webmock/http_lib_adapters/net_http.rb:84:in `request'
5: from /usr/local/lib/ruby/2.7.0/net/http.rb:1492:in `request'
4: from /usr/local/lib/ruby/2.7.0/net/http.rb:1519:in `transport_request'
3: from /usr/local/lib/ruby/2.7.0/net/http.rb:1519:in `catch'
2: from /usr/local/lib/ruby/2.7.0/net/http.rb:1521:in `block in transport_request'
1: from /usr/local/lib/ruby/2.7.0/net/http/generic_request.rb:129:in `exec'
/usr/local/lib/ruby/2.7.0/net/http/generic_request.rb:335:in `write_header': undefined method `write' for #<StubSocket:0x0000564298bf50f0 @closed=true> (NoMethodError)
@zsan thank you for reporting.
Are you able to provide an example code to reproduce it or show more stacktrace to understand where this
write
is called?
Hello,
I just put webmock
in the Gemfile
of my Rails's app, then i put require "webmock/rspec"
in spec_helper.rb
and i have rspec file like this:
require "rails_helper"
RSpec.feature "LoginMethods", type: :feature, js: true do
before do
@google_user = create(:user, login_method: "external", provider: "google_oauth2")
OmniAuth.config.test_mode = true
end
scenario "reject internal login" do
visit new_user_session_path
byebug
fill_in "Email", with: @google_user.email
fill_in "Password", with: @google_user.password
click_button "Sign in"
expect(page).to have_content("This account is for login using Google account.")
end
end
As you can see i put byebug
inside scenario and the error is thrown when i type fill_in "Email", with: @google_user.email
within byebug's prompt.
Just FYI, the error is gone when i tried with 3.18.1
.
Version 3.18.1
works fine for us! Thank you for your quick work!
Sorry for the trouble everyone. I'll investigate further and try to figure out what went wrong here. The core problem seems to be that StubSocket isn't a very convincing stub of a socket.