spec/vcr/test_frameworks/cucumber_spec.rb in vcr-2.0.1 vs spec/vcr/test_frameworks/cucumber_spec.rb in vcr-2.1.0
- old
+ new
@@ -2,10 +2,12 @@
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")) }
# 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
@@ -15,13 +17,13 @@
end
def test_tag(cassette_attribute, tag, expected_value)
VCR.current_cassette.should be_nil
- before_blocks_for_tags[tag].call
+ before_blocks_for_tags[tag].call(current_scenario)
VCR.current_cassette.send(cassette_attribute).should eq(expected_value)
- after_blocks_for_tags[tag].call
+ after_blocks_for_tags[tag].call(current_scenario)
VCR.current_cassette.should be_nil
end
%w(tags tag).each do |tag_method|
@@ -44,9 +46,34 @@
subject.send(tag_method, 'tag1', :record => :none)
subject.send(tag_method, 'tag2', :record => :new_episodes)
test_tag(:record_mode, 'tag1', :none)
test_tag(:record_mode, 'tag2', :new_episodes)
+ end
+
+ context 'with :use_scenario_name as an option' do
+ it "uses the scenario's name as the cassette name" do
+ subject.send(tag_method, 'tag1', :use_scenario_name => true)
+
+ test_tag(:name, 'tag1', 'My feature name/My scenario name')
+ end
+
+ it 'does not pass :use_scenario_name along the given options to the cassette' do
+ subject.send(tag_method, 'tag1', :use_scenario_name => true)
+
+ VCR::Cassette.should_receive(:new).with(anything, hash_not_including(:use_scenario_name))
+ before_blocks_for_tags['tag1'].call(current_scenario)
+ end
+
+ it 'does not modify the options passed to the cassette' do
+ original_options = { :use_scenario_name => true, :record => :none }
+ subject.send(tag_method, 'tag1', original_options)
+ 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
end
end
end
describe '.tags' do