From 034bdaf6935cfc482b807171e0c677f3a967224b Mon Sep 17 00:00:00 2001 From: Myron Marston Date: Mon, 23 Apr 2012 23:11:06 -0700 Subject: [PATCH] Only use the first line of the cuke feature name in the cassette name. Closes #157. --- features/test_frameworks/cucumber.feature | 4 ++++ lib/vcr/test_frameworks/cucumber.rb | 2 +- spec/vcr/test_frameworks/cucumber_spec.rb | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/features/test_frameworks/cucumber.feature b/features/test_frameworks/cucumber.feature index 197f6e7f..283fa081 100644 --- a/features/test_frameworks/cucumber.feature +++ b/features/test_frameworks/cucumber.feature @@ -75,6 +75,10 @@ Feature: Usage with Cucumber """ Feature: VCR example + Note: Cucumber treats the pre-amble as part of the feature name. When + using the :use_scenario_name option, VCR will only use the first line + of the feature name as the directory for the cassette. + @localhost_request Scenario: tagged scenario When a request is made to "http://localhost:7777/localhost_request_1" diff --git a/lib/vcr/test_frameworks/cucumber.rb b/lib/vcr/test_frameworks/cucumber.rb index 86d8c33c..280d7952 100644 --- a/lib/vcr/test_frameworks/cucumber.rb +++ b/lib/vcr/test_frameworks/cucumber.rb @@ -38,7 +38,7 @@ def tags(*tag_names) options = original_options.dup cassette_name = if options.delete(:use_scenario_name) - "#{scenario.feature.name}/#{scenario.name}" + "#{scenario.feature.name.split("\n").first}/#{scenario.name}" else "cucumber_tags/#{tag_name.gsub(/\A@/, '')}" end diff --git a/spec/vcr/test_frameworks/cucumber_spec.rb b/spec/vcr/test_frameworks/cucumber_spec.rb index c14d160d..7675678d 100644 --- a/spec/vcr/test_frameworks/cucumber_spec.rb +++ b/spec/vcr/test_frameworks/cucumber_spec.rb @@ -6,7 +6,7 @@ let(:after_blocks_for_tags) { {} } def scenario(name) - stub(:name => name, :feature => stub(:name => "My feature name")) + stub(:name => name, :feature => stub(:name => "My feature name\nThe preamble text is not included")) end let(:current_scenario) { scenario "My scenario name" }