Sha256: 607047fd995a917efc6d0453a5e6c8e53f56e8994d0a842e7a7de02f9abf8304

Contents?: true

Size: 1.8 KB

Versions: 9

Compression:

Stored size: 1.8 KB

Contents

require 'spec_helper'

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

  # 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)
    VCR.current_cassette.should be_nil

    before_blocks_for_tags[tag].call
    VCR.current_cassette.send(cassette_attribute).should == expected_value
    after_blocks_for_tags[tag].call

    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.11.1 spec/vcr/test_frameworks/cucumber_spec.rb
vcr-1.10.3 spec/vcr/test_frameworks/cucumber_spec.rb
vcr-1.10.2 spec/vcr/test_frameworks/cucumber_spec.rb
vcr-1.10.0 spec/vcr/test_frameworks/cucumber_spec.rb
vcr-1.9.0 spec/vcr/test_frameworks/cucumber_spec.rb
vcr-1.8.0 spec/vcr/test_frameworks/cucumber_spec.rb
vcr-1.7.2 spec/vcr/test_frameworks/cucumber_spec.rb
vcr-1.7.1 spec/vcr/test_frameworks/cucumber_spec.rb
vcr-1.7.0 spec/vcr/test_frameworks/cucumber_spec.rb