When you use Webmock or VCR or both together along with Cucumber, you will face an issue with your tests not being able to record as webmock and vcr blocks all outbound HTTP requests.

You will see error somewhat like this:


The request that is triggering the error looks like it’s coming from Capybara. When you use one of the javascript drivers, capybara boots your app using a simple rack server, and then polls the special__identify__ path so it knows when it has finished booting.

There are few ways to tackle this problem based on your situation

1. If you are only using only Webmock

If you don’t need it, remove it from the Gemfile. If you do need it, then you may need to configure it more precisely to your needs, one thing worked for me is adding this snippet to my env.rb

Screen Shot 2013-09-19 at 11.11.42 AM

By doing so, you allow real web access to your localhost.

2. If you are using vcr & webmock both

If you’re using VCR, you don’t need to configure webmock with the require 'webmock/cucumber' line and the WebMock.allow_net_connect! line. VCR takes care of any necessary WebMock configuration for you.

VCR includes support for ignoring localhost requests so that it won’t interfere with this. The relish docs, but in short you can use this snippet in VCR configuration to get it working.

Create vcr.rb inside feature/support folder and add this:

Screen Shot 2013-09-19 at 11.23.23 AM




If this doesn’t work then follow the detailed documentation at Relish to get it working with cucumber