Sha256: cf995a33275d14983b07cb9df8beffc0ec296ba1f5aaed50fbf0c0599807fc7b

Contents?: true

Size: 1.72 KB

Versions: 1

Compression:

Stored size: 1.72 KB

Contents

require 'spec_helper'

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

describe 'Scenario, Integration' do

  it 'properly sets its child elements' do
    source = ['@a_tag',
              'Scenario: Test scenario',
              '  * a step']
    source = source.join("\n")

    scenario = CucumberAnalytics::Scenario.new(source)
    step = scenario.steps.first
    tag = scenario.tag_elements.first

    step.parent_element.should equal scenario
    tag.parent_element.should equal scenario
  end


  context 'getting stuff' do

    before(:each) do
      source = ['Feature: Test feature',
                '',
                '  Scenario: Test test',
                '    * a step']
      source = source.join("\n")

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

      @directory = CucumberAnalytics::Directory.new(@default_file_directory)
      @scenario = @directory.feature_files.first.features.first.tests.first
    end


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

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

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

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

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

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

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

      test.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/scenario_integration_spec.rb