Sha256: 20bf3c27003906d7831361009638a319358a610eafd8877dd03859461c06fe23

Contents?: true

Size: 1.96 KB

Versions: 1

Compression:

Stored size: 1.96 KB

Contents

require 'spec_helper'

SimpleCov.command_name('Tag') unless RUBY_VERSION.to_s < '1.9.0'

describe 'Tag, Integration' do

  context 'getting stuff' do

    before(:each) do
      source = ['@feature_tag',
                'Feature: Test feature',
                '',
                '  Scenario Outline: Test test',
                '    * a step',
                '',
                '  @example_tag',
                '  Examples: Test example',
                '    | a param |']
      source = source.join("\n")

      file_path = "#{@default_file_directory}/tag_test_file.feature"
      File.open(file_path, 'w') { |file| file.write(source) }

      @directory = CucumberAnalytics::Directory.new(@default_file_directory)
      @tag = @directory.feature_files.first.features.first.tests.first.examples.first.tag_elements.first
      @high_level_tag = @directory.feature_files.first.features.first.tag_elements.first
    end


    it 'can get its directory' do
      directory = @tag.get_ancestor(:directory)

      directory.path.should == @directory.path
    end

    it 'can get its feature file' do
      feature_file = @tag.get_ancestor(:feature_file)

      feature_file.path.should == @directory.feature_files.first.path
    end

    it 'can get its feature' do
      feature = @tag.get_ancestor(:feature)

      feature.name.should == @directory.feature_files.first.features.first.name
    end

    it 'can get its test' do
      test = @tag.get_ancestor(:test)

      test.name.should == @directory.feature_files.first.features.first.tests.first.name
    end

    it 'can get its example' do
      example = @tag.get_ancestor(:example)

      example.name.should == @directory.feature_files.first.features.first.tests.first.examples.first.name
    end

    it 'returns nil if it does not have the requested type of ancestor' do
      example = @high_level_tag.get_ancestor(:example)

      example.should be_nil
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cucumber_analytics-1.3.0 spec/integration/tag_integration_spec.rb