Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

using webmock with cucumber

Tags:

I am using webmock and it is not working for cucumber tests

In my Gemfile

  gem 'vcr'   gem 'webmock' 

And in my features/support.env.rb, I have

require 'webmock/cucumber' WebMock.allow_net_connect! 

When I run my cucumber tests I am getting this error.

    Real HTTP connections are disabled. Unregistered request:  GET http://127.0.0.1:9887/__identify__ with headers  {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent'=>'Ruby'} 

Am I doing anything wrong or is sth missing?

like image 338
Sadiksha Gautam Avatar asked May 25 '11 04:05

Sadiksha Gautam


1 Answers

First off, 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.

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.

VCR includes support for ignoring localhost requests so that it won't interfere with this. The relish docs have the full story but the short version is that you need to add VCR configuration like this:

VCR.config do |c|   c.ignore_localhost = true end 
like image 198
Myron Marston Avatar answered Oct 21 '22 11:10

Myron Marston