Sha256: bb88ebebd099de881274cc74daab38ea49ae93e131c916f6e46c358bdd21e9b7

Contents?: true

Size: 1.82 KB

Versions: 5

Compression:

Stored size: 1.82 KB

Contents

require 'spec_helper'

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

describe 'DocString, Integration' do

  context 'getting stuff' do

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

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

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


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

      directory.should equal @directory
    end

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

      feature_file.should equal @directory.feature_files.first
    end

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

      feature.should equal @directory.feature_files.first.features.first
    end

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

      test.should equal @directory.feature_files.first.features.first.tests.first
    end

    it 'can get its step' do
      step = @doc_string.get_ancestor(:step)

      step.should equal @directory.feature_files.first.features.first.tests.first.steps.first
    end

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

      example.should be_nil
    end

  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
cucumber_analytics-1.5.1 spec/integration/doc_string_integration_spec.rb
cucumber_analytics-1.5.0 spec/integration/doc_string_integration_spec.rb
cucumber_analytics-1.4.2 spec/integration/doc_string_integration_spec.rb
cucumber_analytics-1.4.1 spec/integration/doc_string_integration_spec.rb
cucumber_analytics-1.4.0 spec/integration/doc_string_integration_spec.rb