Sha256: 2aec322e7b58d9c1bc15d7814203e014ded90a545e9b2d3523a14ad75d41c9bd

Contents?: true

Size: 1.48 KB

Versions: 2

Compression:

Stored size: 1.48 KB

Contents

require 'spec_helper'

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

describe 'FeatureFile, Integration' do

  let(:clazz) { CukeModeler::FeatureFile }


  describe 'unique behavior' do

    it 'cannot model a non-existent feature file' do
      path = "#{@default_file_directory}/missing_file.txt"

      expect { clazz.new(path) }.to raise_error(ArgumentError)
    end

    it 'properly sets its child elements' do
      file_path = "#{@default_file_directory}/#{@default_feature_file_name}"

      File.open(file_path, "w") { |file|
        file.puts('Feature: Test feature')
      }

      file = clazz.new(file_path)
      feature = file.feature

      expect(feature.parent_element).to equal(file)
    end

    describe 'getting ancestors' do

      before(:each) do
        file_path = "#{@default_file_directory}/feature_file_test_file.feature"
        File.open(file_path, 'w') { |file| file.write('Feature: Test feature') }
      end

      let(:directory) { CukeModeler::Directory.new(@default_file_directory) }
      let(:feature_file) { directory.feature_files.first }


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

        expect(ancestor).to equal(directory)
      end

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

        expect(ancestor).to 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/feature_file_integration_spec.rb
cuke_modeler-0.4.0 spec/integration/feature_file_integration_spec.rb