Sha256: e9b2c0c46fcb66c8619582f2a3a55f6807e66aeb0b08d52c54496669fb899735

Contents?: true

Size: 1.94 KB

Versions: 2

Compression:

Stored size: 1.94 KB

Contents

require 'spec_helper'

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

describe 'Row, Integration' do

  let(:clazz) { CukeModeler::Row }


  describe 'unique behavior' do

    describe 'getting ancestors' do

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

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

      let(:directory) { CukeModeler::Directory.new(@default_file_directory) }
      let(:row) { directory.feature_files.first.features.first.tests.first.examples.first.row_elements.first }


      it 'can get its directory' do
        ancestor = row.get_ancestor(:directory)

        ancestor.should equal directory
      end

      it 'can get its feature file' do
        ancestor = row.get_ancestor(:feature_file)

        ancestor.should equal directory.feature_files.first
      end

      it 'can get its feature' do
        ancestor = row.get_ancestor(:feature)

        ancestor.should equal directory.feature_files.first.features.first
      end

      it 'can get its test' do
        ancestor = row.get_ancestor(:test)

        ancestor.should equal directory.feature_files.first.features.first.tests.first
      end

      it 'can get its example' do
        ancestor = row.get_ancestor(:example)

        ancestor.should equal directory.feature_files.first.features.first.tests.first.examples.first
      end

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

        ancestor.should be_nil
      end

    end

  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
cuke_modeler-0.4.1 spec/integration/row_integration_spec.rb
cuke_modeler-0.4.0 spec/integration/row_integration_spec.rb