FakeWeb stops @javascript (capybara & selenium) cukes from running. #25

Open
sfsekaran opened this Issue Feb 20, 2011 · 22 comments

Comments

@sfsekaran

fakeweb 1.3.0
cucumber-rails 0.3.2
capybara 0.4.1.1

When I allow Bundler to require the fakeweb gem, any of the @javascript cukes will hang at certain (seemingly random) steps. Some steps just hang for a long time and then continue. I'm not sure what the catalyst is, but it's really disappointing. I really want to move from Artifice to FakeWeb or WebMock, but both gems do the same thing to our selenium scenarios.

I wonder if anyone else has run into this.

This is the stacktrace when I Ctrl-c after it hangs indefinitely:

/Users/sfsekaran/.rvm/rubies/ree- 1.8.7-2011.01/lib/ruby/1.8/net/http.rb:560:in `initialize': Connection refused - connect(2) (Errno::ECONNREFUSED)
from /Users/sfsekaran/.rvm/rubies/ree-1.8.7-2011.01/lib/ruby/1.8/net/http.rb:560:in `open'
from /Users/sfsekaran/.rvm/rubies/ree-1.8.7-2011.01/lib/ruby/1.8/net/http.rb:560:in `connect_without_fakeweb'
from /Users/sfsekaran/.rvm/rubies/ree-1.8.7-2011.01/lib/ruby/1.8/timeout.rb:53:in `timeout'
from /Users/sfsekaran/.rvm/rubies/ree-1.8.7-2011.01/lib/ruby/1.8/timeout.rb:101:in `timeout'
from /Users/sfsekaran/.rvm/rubies/ree-1.8.7-2011.01/lib/ruby/1.8/net/http.rb:560:in `connect_without_fakeweb'
from /Users/sfsekaran/.rvm/gems/ree-1.8.7-2011.01/gems/fakeweb-1.3.0/lib/fake_web/ext/net_http.rb:49:in `request'
from /Users/sfsekaran/.rvm/gems/ree-1.8.7-2011.01/gems/selenium-webdriver-0.1.2/lib/selenium/webdriver/remote/http/default.rb:36:in `request'
from /Users/sfsekaran/.rvm/gems/ree-1.8.7-2011.01/gems/selenium-webdriver-0.1.2/lib/selenium/webdriver/remote/http/common.rb:36:in `call'
from /Users/sfsekaran/.rvm/gems/ree-1.8.7-2011.01/gems/selenium-webdriver-0.1.2/lib/selenium/webdriver/remote/bridge.rb:429:in `raw_execute'
from /Users/sfsekaran/.rvm/gems/ree-1.8.7-2011.01/gems/selenium-webdriver-0.1.2/lib/selenium/webdriver/remote/bridge.rb:407:in `execute'
from /Users/sfsekaran/.rvm/gems/ree-1.8.7-2011.01/gems/selenium-webdriver-0.1.2/lib/selenium/webdriver/remote/bridge.rb:170:in `quit'
from /Users/sfsekaran/.rvm/gems/ree-1.8.7-2011.01/gems/selenium-webdriver-0.1.2/lib/selenium/webdriver/firefox/bridge.rb:42:in `quit'
from /Users/sfsekaran/.rvm/gems/ree-1.8.7-2011.01/gems/selenium-webdriver-0.1.2/lib/selenium/webdriver/common/driver.rb:156:in `quit'
from /Users/sfsekaran/.rvm/gems/ree-1.8.7-2011.01/gems/capybara-0.4.1.1/lib/capybara/driver/selenium_driver.rb:96:in `browser'
from bin/cucumber:16
@jeromelefeuvre

This comment has been minimized.

Show comment
Hide comment
@jeromelefeuvre

jeromelefeuvre Apr 19, 2011

same on my side but with a timeout::Error ;(

  
execution expired (Timeout::Error)
/Users/james/.rvm/rubies/ree-1.8.7-2011.03/lib/ruby/1.8/timeout.rb:64:in `rbuf_fill'
/Users/james/.rvm/rubies/ree-1.8.7-2011.03/lib/ruby/1.8/net/protocol.rb:134:in `rbuf_fill'
/Users/james/.rvm/rubies/ree-1.8.7-2011.03/lib/ruby/1.8/net/protocol.rb:116:in `readuntil'
/Users/james/.rvm/rubies/ree-1.8.7-2011.03/lib/ruby/1.8/net/protocol.rb:126:in `readline'
/Users/james/.rvm/rubies/ree-1.8.7-2011.03/lib/ruby/1.8/net/http.rb:2028:in `read_status_line'
/Users/james/.rvm/rubies/ree-1.8.7-2011.03/lib/ruby/1.8/net/http.rb:2017:in `read_new'
/Users/james/.rvm/rubies/ree-1.8.7-2011.03/lib/ruby/1.8/net/http.rb:1051:in `request_without_fakeweb'
/Users/james/.rvm/rubies/ree-1.8.7-2011.03/lib/ruby/1.8/net/http.rb:1037:in `request_without_fakeweb'
/Users/james/.rvm/rubies/ree-1.8.7-2011.03/lib/ruby/1.8/net/http.rb:543:in `start'
/Users/james/.rvm/rubies/ree-1.8.7-2011.03/lib/ruby/1.8/net/http.rb:1035:in `request_without_fakeweb'
./features/step_definitions/web_steps.rb:42
./features/step_definitions/web_steps.rb:15:in `with_scope'
./features/step_definitions/web_steps.rb:41:in `/^(?:|I )fill in "([^"]*)" with "([^"]*)"(?: within "([^"]*)")?$/'
  

same on my side but with a timeout::Error ;(

  
execution expired (Timeout::Error)
/Users/james/.rvm/rubies/ree-1.8.7-2011.03/lib/ruby/1.8/timeout.rb:64:in `rbuf_fill'
/Users/james/.rvm/rubies/ree-1.8.7-2011.03/lib/ruby/1.8/net/protocol.rb:134:in `rbuf_fill'
/Users/james/.rvm/rubies/ree-1.8.7-2011.03/lib/ruby/1.8/net/protocol.rb:116:in `readuntil'
/Users/james/.rvm/rubies/ree-1.8.7-2011.03/lib/ruby/1.8/net/protocol.rb:126:in `readline'
/Users/james/.rvm/rubies/ree-1.8.7-2011.03/lib/ruby/1.8/net/http.rb:2028:in `read_status_line'
/Users/james/.rvm/rubies/ree-1.8.7-2011.03/lib/ruby/1.8/net/http.rb:2017:in `read_new'
/Users/james/.rvm/rubies/ree-1.8.7-2011.03/lib/ruby/1.8/net/http.rb:1051:in `request_without_fakeweb'
/Users/james/.rvm/rubies/ree-1.8.7-2011.03/lib/ruby/1.8/net/http.rb:1037:in `request_without_fakeweb'
/Users/james/.rvm/rubies/ree-1.8.7-2011.03/lib/ruby/1.8/net/http.rb:543:in `start'
/Users/james/.rvm/rubies/ree-1.8.7-2011.03/lib/ruby/1.8/net/http.rb:1035:in `request_without_fakeweb'
./features/step_definitions/web_steps.rb:42
./features/step_definitions/web_steps.rb:15:in `with_scope'
./features/step_definitions/web_steps.rb:41:in `/^(?:|I )fill in "([^"]*)" with "([^"]*)"(?: within "([^"]*)")?$/'
  
@sfsekaran

This comment has been minimized.

Show comment
Hide comment
@sfsekaran

sfsekaran Apr 19, 2011

Somehow, Artifice does the job of removing itself when deactivated much better. As cool as Artifice is, it's a bit outdated compared to FakeWeb or WebMock, and it would be nice to have the option to switch, at least.

I wonder if it's possible to do like Artifice does and save the original version of Net::HTTP in a constant and simply swap it in when FakeWeb is deactivated.

Somehow, Artifice does the job of removing itself when deactivated much better. As cool as Artifice is, it's a bit outdated compared to FakeWeb or WebMock, and it would be nice to have the option to switch, at least.

I wonder if it's possible to do like Artifice does and save the original version of Net::HTTP in a constant and simply swap it in when FakeWeb is deactivated.

@tommeier

This comment has been minimized.

Show comment
Hide comment
@tommeier

tommeier Jun 1, 2011

+1 on the timeout issue, mine is with capybara and selenium.. seems to be random.

tommeier commented Jun 1, 2011

+1 on the timeout issue, mine is with capybara and selenium.. seems to be random.

@tsdbrown

This comment has been minimized.

Show comment
Hide comment
@tsdbrown

tsdbrown Jun 7, 2011

+1 for the Timeout::Error (capybara & selenium)

tsdbrown commented Jun 7, 2011

+1 for the Timeout::Error (capybara & selenium)

@felixandersen

This comment has been minimized.

Show comment
Hide comment
@felixandersen

felixandersen Jul 2, 2011

+1
I get the Timeout::Error too

capybara 1.0.0
fakeweb 1.3.0
cucumber-rails 1.0.2

+1
I get the Timeout::Error too

capybara 1.0.0
fakeweb 1.3.0
cucumber-rails 1.0.2

@aeden

This comment has been minimized.

Show comment
Hide comment
@aeden

aeden Jul 13, 2011

Ditto, I'm seeing the same behavior. FWIW, I can specify :require => false on fakeweb in Bundler and then the problem goes away.

aeden commented Jul 13, 2011

Ditto, I'm seeing the same behavior. FWIW, I can specify :require => false on fakeweb in Bundler and then the problem goes away.

@sfsekaran

This comment has been minimized.

Show comment
Hide comment
@sfsekaran

sfsekaran Jul 13, 2011

I guess the whole point for us was to make sure our cucumber scenarios didn't hit outside sources, so even when I added :require => false, I'd still have to include it somewhere in order to block external calls. And we even tried only enabling it for non @javascript cukes, but just the same, I think it messed with Net::HTTP enough to make the selenium tests hang indefinitely.

I guess the whole point for us was to make sure our cucumber scenarios didn't hit outside sources, so even when I added :require => false, I'd still have to include it somewhere in order to block external calls. And we even tried only enabling it for non @javascript cukes, but just the same, I think it messed with Net::HTTP enough to make the selenium tests hang indefinitely.

@aeden

This comment has been minimized.

Show comment
Hide comment
@aeden

aeden Jul 13, 2011

I actually want my cucumber scenarios to hit outside resources, which is why my solution worked for me. :-)

aeden commented Jul 13, 2011

I actually want my cucumber scenarios to hit outside resources, which is why my solution worked for me. :-)

@sfsekaran

This comment has been minimized.

Show comment
Hide comment
@sfsekaran

sfsekaran Jul 13, 2011

Fair enough :)

Fair enough :)

@yulrizka

This comment has been minimized.

Show comment
Hide comment
@yulrizka

yulrizka Aug 7, 2011

Yup facing the same problem, it tooks me 3 hour that the error related to fake web -_-

yulrizka commented Aug 7, 2011

Yup facing the same problem, it tooks me 3 hour that the error related to fake web -_-

@rahilsondhi

This comment has been minimized.

Show comment
Hide comment

+1

@pedromenezes

This comment has been minimized.

Show comment
Hide comment

+1

@oreoshake

This comment has been minimized.

Show comment
Hide comment
@oreoshake

oreoshake Sep 16, 2011

http://ahmy.yulrizka.com/2011/08/cucumber-timeouterror-timeouterror-on-fakeweb/

The sollution for me is add :require => false to the Gemfile

gem 'fakeweb', :require => false

and only require fakeweb on rspec by including it on spec/spec_helper.rb

require 'fakeweb'

http://ahmy.yulrizka.com/2011/08/cucumber-timeouterror-timeouterror-on-fakeweb/

The sollution for me is add :require => false to the Gemfile

gem 'fakeweb', :require => false

and only require fakeweb on rspec by including it on spec/spec_helper.rb

require 'fakeweb'

@sfsekaran

This comment has been minimized.

Show comment
Hide comment
@sfsekaran

sfsekaran Sep 16, 2011

Yeah, I think that's what most of us have done so far, but the whole point was to not let cucumber hit outside sources.

See my earlier comment here.

Yeah, I think that's what most of us have done so far, but the whole point was to not let cucumber hit outside sources.

See my earlier comment here.

@sfsekaran

This comment has been minimized.

Show comment
Hide comment
@sfsekaran

sfsekaran Sep 16, 2011

Interestingly enough, on that link you posted, a commenter said this:

There is a problem with Fakeweb which breaks normal Net::HTTP behaviour and leads to this Timeout::Error. I had the same problem in WebMock (since WebMock Net::HTTP adapter is based on Fakeweb) but it's now fixed in the new WebMock 1.7.0.

If that's the case, I'll probably use WebMock. But it would be cool if FakeWeb could adopt the changes which fixed that. (If it really is fixed for WebMock, that is.)

Interestingly enough, on that link you posted, a commenter said this:

There is a problem with Fakeweb which breaks normal Net::HTTP behaviour and leads to this Timeout::Error. I had the same problem in WebMock (since WebMock Net::HTTP adapter is based on Fakeweb) but it's now fixed in the new WebMock 1.7.0.

If that's the case, I'll probably use WebMock. But it would be cool if FakeWeb could adopt the changes which fixed that. (If it really is fixed for WebMock, that is.)

@oriolgual

This comment has been minimized.

Show comment
Hide comment
@oriolgual

oriolgual Sep 16, 2011

@sfsekaran I switched to webmock and work fine.

@sfsekaran I switched to webmock and work fine.

@sfsekaran

This comment has been minimized.

Show comment
Hide comment
@sfsekaran

sfsekaran Sep 16, 2011

Good to know, thanks!

Good to know, thanks!

@jsanders

This comment has been minimized.

Show comment
Hide comment
@jsanders

jsanders Oct 13, 2011

This is a big issue. Is the recommendation just to switch to WebMock, or will this be fixed at some point?

This is a big issue. Is the recommendation just to switch to WebMock, or will this be fixed at some point?

@clowder

This comment has been minimized.

Show comment
Hide comment

clowder commented Oct 27, 2011

+1

@jamesarosen

This comment has been minimized.

Show comment
Hide comment
@jamesarosen

jamesarosen Feb 14, 2012

I found a decent solution was to allow Selenium requests in all specs:

selenium_requests = %r{/((__.+__)|(hub/session.*))$}
FakeWeb.allow_net_connect = selenium_requests

It's unlikely that other requests would match that expression, but you might be able to make it more restrictive if you were to find such a beast.

I found a decent solution was to allow Selenium requests in all specs:

selenium_requests = %r{/((__.+__)|(hub/session.*))$}
FakeWeb.allow_net_connect = selenium_requests

It's unlikely that other requests would match that expression, but you might be able to make it more restrictive if you were to find such a beast.

@jsanders

This comment has been minimized.

Show comment
Hide comment
@sorentwo

This comment has been minimized.

Show comment
Hide comment
@sorentwo

sorentwo Jul 13, 2012

The selenium requests solution by @jamesarosen didn't work for me. Switched to webmock and everything is great. I only need it for VCR anyhow, so it was no hassle.

The selenium requests solution by @jamesarosen didn't work for me. Switched to webmock and everything is great. I only need it for VCR anyhow, so it was no hassle.

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