Mike GehardMike Gehard
Rails3, Caypbara, Cucumber, FakeWeb...oh my....
edit Posted by Mike Gehard on Thursday November 04, 2010 at 07:57PM

While helping client upgrade a Rails 2.3.10 site to Rails 3.0.1, I came across a very perplexing problem with our WebDriver based Cucumber tests that all worked fine under 2.3.10.

We were "randomly" getting some very strange errors from Cucumber having to do with timeout problems and other strangeness like Cucumber not being able to find form fields to fill in.

The solution: 1) require => false for the FakeWeb line in the Gemfile 2) add require 'fakeweb' to the top of the test_helper.rb file

or optionally scrap FakeWeb for either Artifice or WebMock

It has something to do with FakeWeb inserting it into the HTTP stack strangely even if you tell it to allow non-local HTTP requests. We weren't seeing it in 2.3.10 because we were using a cucumber environment to run the cucumber tests. Now under 3.0.1 we run the cucumber tests in the test environment.

I wish I had some more details but I was just happy to move past this strangeness so I didn't really look back.

Comments

  1. Mat Schaffer Mat Schaffer on November 05, 2010 at 06:15AM

    What did you guys use to tell Artifice allow local requests? We had to do some interesting un-monkeypatching in our latest project for that. Is there a better way?

    Here's the crux of what we did: https://gist.github.com/664127

  2. Mike Gehard Mike Gehard on November 05, 2010 at 04:50PM

    Sorry...we haven't actually switched to Artifice yet so I can't help with that.

  3. jari jari on November 06, 2010 at 02:58AM

    WebDriver's internals do use Net::HTTP by default to communicate with the browsers. You can avoid the Net::HTTP stack completely by using the provided Curb client or your own implementation - check "Using Curb or your own HTTP client" here:

    http://code.google.com/p/selenium/wiki/RubyBindings