Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using VCR with Cucumber via tags

I have some Cucumber features which need to interact with the Google Maps Routing API. I'm trying to stub out these interactions using VCR.

I have added a VCR tag to my features like so:

@google_routing_api @javascript
Scenario: Creating a bus
  Given I am on the buses page
  When I follow "Get Started Now"

And then added my VCR configuration in features/support/vcr.rb

require 'vcr'

VCR.config do |c|
  # INFO: This is relative to the Rails.root
  c.cassette_library_dir = 'features/fixtures/vcr_cassettes'
  c.stub_with :fakeweb
end

# INFO: https://github.com/myronmarston/vcr/wiki/Usage-with-Cucumber
VCR.cucumber_tags do |t|
  t.tag '@google_routing_api'
end

But when I run my cukes, I am told..

Real HTTP connections are disabled. Unregistered request: GET http://127.0.0.1:54181/__identify__
like image 736
David Tuite Avatar asked Nov 16 '11 07:11

David Tuite


1 Answers

You have to set VCR to ignore localhost requests. Otherwise, when capybara tries to request any page from your website, VCR will block it.

Add c.ignore_localhost = true to your VCR config block.

VCR.config do |c|
  c.cassette_library_dir = 'features/fixtures/vcr_cassettes'
  c.stub_with :fakeweb
  c.ignore_localhost = true
end
like image 138
David Tuite Avatar answered Nov 10 '22 08:11

David Tuite