Sha256: 7642cfb830cd1fca6f9be1f8eb6c70bce73a985ee9fee9f260eade873493a34f

Contents?: true

Size: 1.49 KB

Versions: 2

Compression:

Stored size: 1.49 KB

Contents

# File: gherkin-listener_spec.rb

require_relative '../spec_helper'
require_relative 'file-parsing'

# Load the class under testing
require_relative '../../lib/cukedep/gherkin-listener'

module Cukedep # Open module to get rid of long qualified names
describe GherkinListener do
  include FileParsing # Use mixin module to parse of sample feature files

  subject { GherkinListener.new }

  context 'Creation and initialization:' do
    it 'should be created without argument' do
      expect { GherkinListener.new }.not_to raise_error
    end

    it 'should have no feature file at start' do
      expect(subject.feature_files.size).to eq(0)
    end
  end # context

  context 'Provided services:' do
    it 'should build a FeatureFileRep per parsed file' do
      parse_for(subject)
      expect(subject.feature_files.size)
        .to eq(FileParsing::SampleFileNames.size)
    end

    it 'should know the tags of each feature' do
      parse_for(subject)

      expectations = [
        %w(a_few feature:qux),
        %w(some feature:foo depends_on:bar depends_on:qux),
        %w(still_other feature:baz),
        %w(yet_other feature:bar depends_on:baz depends_on:qux depends_on:quux),
        %w(feature:quux more),
        []
      ]

      # Sort the expectations to ease further comparison
      expectations.map!(&:sort)

      subject.feature_files.each_with_index do |file, i|
        expect(file.feature.tags.sort).to eq(expectations[i])
      end
    end
  end # context
end # describe
end # module

# End of file

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
cukedep-0.2.01 spec/cukedep/gherkin-listener_spec.rb
cukedep-0.2.00 spec/cukedep/gherkin-listener_spec.rb