Search code examples
ruby-on-railsruby-on-rails-3rspeccucumbervcr

Where to put VCR config when using both rspec and cucumber


I'm using both rspec and cucumber. Cucumber of integration level tests, but rspec for unit tests.

I'm using vcr for cucumber already, but want to use it for rspec, too. Where's the right place to put the vcr configuration? I'd rather not replicate it in both features/support and rspec/support.


Solution

  • Cucumber doesn't "know" about RSpec, nor vice-versa. If you don't want to duplicate it, define it in its own file, say spec/support/vcr_setup.rb, and then include that in both.

    features/support/env.rb:
    require File.expand_path("../../../spec/support/vcr_setup", __FILE__)
    (think that's right, adjust path as needed)

    spec/spec_helper.rb:
    require "support/vcr_setup"