Sha256: 9b4a44432c7d8b9a2264f8e3d8d674f490bdec3ce2d60aef62a2c343ddffc848

Contents?: true

Size: 1.72 KB

Versions: 11

Compression:

Stored size: 1.72 KB

Contents

module Cucumber
  module Ast
    # Represents the root node of a parsed feature.
    class Feature
      attr_accessor :file
      attr_writer :features, :lines

      def initialize(comment, tags, name, feature_elements)
        @comment, @tags, @name, @feature_elements = comment, tags, name, feature_elements
        feature_elements.each{|feature_element| feature_element.feature = self}
        @lines = []
      end

      def tagged_with?(tag_names, check_elements=true)
        @tags.among?(tag_names) || 
        (check_elements && @feature_elements.detect{|e| e.tagged_with?(tag_names)})
      end
      
      def matches_scenario_names?(scenario_names)
        @feature_elements.detect{|e| e.matches_scenario_names?(scenario_names)}
      end

      def accept(visitor)
        visitor.current_feature_lines = @lines
        visitor.visit_comment(@comment)
        visitor.visit_tags(@tags)
        visitor.visit_feature_name(@name)
        @feature_elements.each do |feature_element|
          visitor.visit_feature_element(feature_element) if @features.visit?(feature_element, @lines)
        end
      end

      def scenario_executed(scenario)
        @features.scenario_executed(scenario) if @features
      end

      def step_executed(step)
        @features.step_executed(step) if @features
      end

      def backtrace_line(step_name, line)
        "#{file_line(line)}:in `#{step_name}'"
      end

      def file_line(line)
        "#{@file}:#{line}"
      end

      def to_sexp
        sexp = [:feature, @name]
        comment = @comment.to_sexp
        sexp += [comment] if comment
        tags = @tags.to_sexp
        sexp += tags if tags.any?
        sexp += @feature_elements.map{|e| e.to_sexp}
        sexp
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
aslakhellesoy-cucumber-0.1.16.5 lib/cucumber/ast/feature.rb
aslakhellesoy-cucumber-0.1.99.1 lib/cucumber/ast/feature.rb
aslakhellesoy-cucumber-0.1.99.10 lib/cucumber/ast/feature.rb
aslakhellesoy-cucumber-0.1.99.11 lib/cucumber/ast/feature.rb
aslakhellesoy-cucumber-0.1.99.2 lib/cucumber/ast/feature.rb
aslakhellesoy-cucumber-0.1.99.3 lib/cucumber/ast/feature.rb
aslakhellesoy-cucumber-0.1.99.5 lib/cucumber/ast/feature.rb
aslakhellesoy-cucumber-0.1.99.6 lib/cucumber/ast/feature.rb
aslakhellesoy-cucumber-0.1.99.7 lib/cucumber/ast/feature.rb
aslakhellesoy-cucumber-0.1.99.8 lib/cucumber/ast/feature.rb
aslakhellesoy-cucumber-0.1.99.9 lib/cucumber/ast/feature.rb