Sha256: 5220300f2227eb253a7fd4de892b36717fc7694f4f25c6b32d1be007955b0627

Contents?: true

Size: 1.76 KB

Versions: 9

Compression:

Stored size: 1.76 KB

Contents

require 'spec_helper'

describe VCR::CucumberTags do
  subject { described_class.new(self) }
  let(:blocks_for_tags) { {} }

  # define our own Around so we can test this in isolation from cucumber's implementation.
  def Around(tag, &block)
    blocks_for_tags[tag.sub('@', '')] = block
  end

  def test_tag(cassette_attribute, tag, expected_value)
    VCR.current_cassette.should be_nil

    cassette_during_scenario = nil
    scenario = lambda { cassette_during_scenario = VCR.current_cassette }
    blocks_for_tags[tag].call(:scenario_name, scenario)
    cassette_during_scenario.send(cassette_attribute).should == expected_value

    VCR.current_cassette.should be_nil
  end

  %w(tags tag).each do |tag_method|
    describe "##{tag_method}" do
      it "creates a cucumber Around hook for each given tag so that the scenario runs with the cassette inserted" do
        subject.send(tag_method, 'tag1', 'tag2')

        test_tag(:name, 'tag1', 'cucumber_tags/tag1')
        test_tag(:name, 'tag2', 'cucumber_tags/tag2')
      end

      it "works with tags that start with an @" do
        subject.send(tag_method, '@tag1', '@tag2')

        test_tag(:name, 'tag1', 'cucumber_tags/tag1')
        test_tag(:name, 'tag2', 'cucumber_tags/tag2')
      end

      it "passes along the given options to the cassette" do
        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
    end
  end

  describe '.tags' do
    it 'returns the list of cucumber tags' do
      subject.tags 'tag1', 'tag2'
      subject.tags 'tag3', 'tag4'
      described_class.tags[-4, 4].should == %w(@tag1 @tag2 @tag3 @tag4)
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
vcr-1.6.0 spec/vcr/cucumber_tags_spec.rb
vcr-1.5.1 spec/vcr/cucumber_tags_spec.rb
vcr-1.5.0 spec/vcr/cucumber_tags_spec.rb
vcr-1.4.0 spec/cucumber_tags_spec.rb
vcr-1.3.3 spec/cucumber_tags_spec.rb
vcr-1.3.2 spec/cucumber_tags_spec.rb
vcr-1.3.1 spec/cucumber_tags_spec.rb
vcr-1.3.0 spec/cucumber_tags_spec.rb
vcr-1.2.0 spec/cucumber_tags_spec.rb