Pivotal Labs

Main menu

Skip to primary content
Skip to secondary content
  • About
  • Case Studies
  • Team
    • Executives
    • Locations
      • San Francisco (HQ)
      • Boston
      • Boulder
      • Denver
      • London
      • Los Angeles
      • New York
  • Community
    • Blogs
    • Tech Talks
    • Events
  • Careers
    • Lifestyle
    • Principles & Practices
    • Benefits
    • FAQ
    • Apply
  • Contact
    • Press Room
    • Press Releases
    • In The News
    • Press Kit
  • All
  • Labs
  • Standup
  • Tracker
Danny Burkes

Making WebMock, Selenium, and WebDriver Play Nicely

Danny Burkes
Friday, June 10, 2011

Update

Since this article was written, version 1.7.0 of WebMock has been released, which includes WebMock.disable! functionality, as well as fixes the problem with selenium-webdriver. So please use that, instead of webmock-disabler.

The Problem

Recently, one of my projects ran into a problem where our integration tests would intermittently fail with weird timeout errors and complaints about page elements that couldn’t be found.

A little googling revealed that we weren’t the only ones having this problem.

Apparently, WebMock, Selenium, and WebDriver don’t play nicely together, even if you tell WebMock to allow the outgoing connections necessary to drive the browser.

Some Gemfile hacking revealed that it was the mere presence of WebMock that caused the error. If we removed WebMock from our Gemfile, our integration tests ran fine, but then of course all of our tests that actually needed WebMock failed.

At that point, we could have decided to run our integration tests separately from the rest of the tests, but we really liked the idea of having all the tests run in the same VM, to avoid the duplicate VM startup time.

What we really needed was a way to turn WebMock on and off selectively for different types of tests.

The Solution

With some gnarly monkey patching and offensive use of alias_method, I have created webmock-disabler, a gem which provides new WebMock.disable! and WebMock.enable! methods. You can use these methods in individual tests, or on classes of tests as shown in the README.

The Result

We’re now able to run our tests that need WebMock in the same VM as those that would otherwise break if we didn’t do WebMock.disable!.

Celebration time!

  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Pivotal Labs

Standup 7/20/2010: The Daily Rubymine

Pivotal Labs
Tuesday, July 20, 2010

Interesting Things

  • RubyMine 2.0.2, refactor => extract partial == FAIL. If you select multiple divs and perform
    extract partial, the selected region is removed, but only the first complete div is included in
    the new partial.

  • Rspec/Rubymine focused tests. Rubymine attempts to run focused tests using the
    --example 'text' option. Rspec apparently finds the example group, and runs the examples that are
    directly a part of that example group, but does not include descendent example groups — *which can
    lead you to think examples are passing that were not actually run*. Apparently this is
    fixed in rspec 2.

Ask for Help

“Display of time is off by an hour, presumably due to Daylight Saving Time”

The team is displaying time stored as utc in the database, using strftime, and the time is off by an hour.

“Binding Click to Checkbox with Jquery”

A team was trying to check the value of a checkbox during the click event, but getting the opposite
value. They worked through it but was hoping to find a better solution.

“Why is there a new default for include_root_in_json for rails 3?”

Just curious.

“Fakeweb, Capybara w/Selenium Webdriver == end of file?”

Getting “end of file” failure on CI. There were a few suggestions:

  • There is a fork of fakeweb that allows it to ignore localhost.
  • Consider using Webmock instead of fakeweb.
  • 0 Shares
  • Share on Facebook
  • Share on Twitter

Topics

  • agile (778)
  • rails (113)
  • testing (87)
  • ruby (83)
  • ruby on rails (70)
  • jobs (62)
  • javascript (54)
  • techtalk (44)
  • rspec (38)
  • activerecord (29)
  • productivity (29)
  • gogaruco (29)
  • ironblogger (29)
  • git (28)
  • nyc (27)
  • rubymine (25)
  • bloggerdome (22)
  • mobile (22)
  • cucumber (20)
  • process (19)
  • pivotal tracker (19)
  • jasmine (19)
  • design (18)
  • ios (18)
  • webos (17)
  • objective-c (17)
  • android (16)
  • palm (16)
  • "soft" ware (16)
  • fun (15)
  • tracker ecosystem (15)
  • ci (15)
  • cedar (15)
  • rails3 (14)
  • performance (14)
  • bdd (14)
  • gem (13)
  • tdd (13)
  • selenium (12)
  • css (12)
  • goruco (12)
  • bundler (12)
  • meetup (11)
  • railsconf (11)
  • nyc-standup (11)
  • capybara (10)
  • mac (10)
  • mojo (10)
  • chef (10)
  • api (10)
Subscribe to webmock Feed
  • About
  • Case Studies
  • Team
  • Community
  • Careers
  • Contact
  • Labs
  • Events

Contact Us

contact@pivotallabs.com
+1 415-77-PIVOT
TwitterLinkedInFacebook

Pivotal Tracker

Tracker is the award-winning agile project management tool that enables real-time collaboration around a shared, prioritized backlog.
Visit pivotaltracker.com >