spec/vcr/test_frameworks/cucumber_spec.rb in vcr-2.1.0 vs spec/vcr/test_frameworks/cucumber_spec.rb in vcr-2.1.1

- old
+ new

@@ -2,28 +2,32 @@ describe VCR::CucumberTags do subject { described_class.new(self) } let(:before_blocks_for_tags) { {} } let(:after_blocks_for_tags) { {} } - let(:current_scenario) { stub(:name => "My scenario name", - :feature => stub(:name => "My feature name")) } + def scenario(name) + stub(:name => name, :feature => stub(:name => "My feature name\nThe preamble text is not included")) + end + + let(:current_scenario) { scenario "My scenario name" } + # define our own Before/After so we can test this in isolation from cucumber's implementation. def Before(tag, &block) before_blocks_for_tags[tag.sub('@', '')] = block end def After(tag, &block) after_blocks_for_tags[tag.sub('@', '')] = block end - def test_tag(cassette_attribute, tag, expected_value) + def test_tag(cassette_attribute, tag, expected_value, scenario=current_scenario) VCR.current_cassette.should be_nil - before_blocks_for_tags[tag].call(current_scenario) + before_blocks_for_tags[tag].call(scenario) VCR.current_cassette.send(cassette_attribute).should eq(expected_value) - after_blocks_for_tags[tag].call(current_scenario) + after_blocks_for_tags[tag].call(scenario) VCR.current_cassette.should be_nil end %w(tags tag).each do |tag_method| @@ -70,9 +74,16 @@ before_blocks_for_tags['tag1'].call(current_scenario) original_options.should have(2).items original_options[:use_scenario_name].should eq(true) original_options[:record].should eq(:none) + end + + it "works properly when multiple scenarios use the tag" do + subject.send(tag_method, 'tag1', :use_scenario_name => true) + + test_tag(:name, 'tag1', 'My feature name/Foo', scenario("Foo")) + test_tag(:name, 'tag1', 'My feature name/Bar', scenario("Bar")) end end end end