RailsCasts Pro episodes are now free!

Learn more or hide this

Urban Hafner's Profile

GitHub User: ujh

Site: http://bettong.net

Comments by Urban Hafner

Avatar

This still doesn't work when you have cucumber backgrounds as the around hook gets executed after (!) the background is executed.

Avatar

This is a great start. However, it doesn't work with Scenario Outlines. The following does however:

ruby
Around('@vcr') do |scenario, block|
  s_name = scenario.name.underscore.gsub(/[^\w]+/, "_").gsub(/^_/,'').gsub(/_$/,'')
  if scenario.respond_to? :scenario_outline
    feature = scenario.scenario_outline.feature
  else
    feature = scenario.feature
  end
  f_name = feature.name.underscore.gsub(/[^\w\/]+/, "_")
  VCR.use_cassette("/#{f_name}/#{s_name}", record: :once) { block.call }
end