Sha256: 9138a3f1637c5c01e350100ca0ede82afbc55da6073b55683106557c8161a47f

Contents?: true

Size: 966 Bytes

Versions: 11

Compression:

Stored size: 966 Bytes

Contents

module VCR
  class CucumberTags
    class << self
      def tags
        @tags.dup
      end

      def add_tag(tag)
        @tags << tag
      end
    end

    @tags = []
    def initialize(main_object)
      @main_object = main_object
    end

    def tags(*tag_names)
      options = tag_names.last.is_a?(::Hash) ? tag_names.pop : {}
      tag_names.each do |tag_name|
        tag_name = "@#{tag_name}" unless tag_name =~ /^@/
        cassette_name = "cucumber_tags/#{tag_name.gsub(/\A@/, '')}"

        # It would be nice to use an Around hook here, but
        # cucumber has a bug: background steps do not run
        # within an around hook.
        # https://gist.github.com/652968
        @main_object.Before(tag_name) do
          VCR.insert_cassette(cassette_name, options)
        end

        @main_object.After(tag_name) do
          VCR.eject_cassette
        end

        self.class.add_tag(tag_name)
      end
    end
    alias :tag :tags
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
vcr-1.11.3 lib/vcr/test_frameworks/cucumber.rb
vcr-1.11.2 lib/vcr/test_frameworks/cucumber.rb
vcr-1.11.1 lib/vcr/test_frameworks/cucumber.rb
vcr-1.10.3 lib/vcr/test_frameworks/cucumber.rb
vcr-1.10.2 lib/vcr/test_frameworks/cucumber.rb
vcr-1.10.0 lib/vcr/test_frameworks/cucumber.rb
vcr-1.9.0 lib/vcr/test_frameworks/cucumber.rb
vcr-1.8.0 lib/vcr/test_frameworks/cucumber.rb
vcr-1.7.2 lib/vcr/test_frameworks/cucumber.rb
vcr-1.7.1 lib/vcr/test_frameworks/cucumber.rb
vcr-1.7.0 lib/vcr/test_frameworks/cucumber.rb