Class: Cucumber::Ast::Feature
Overview
Represents the root node of a parsed feature.
Instance Attribute Summary collapse
-
#features ⇒ Object
writeonly
Sets the attribute features.
-
#file ⇒ Object
Returns the value of attribute file.
-
#lines ⇒ Object
writeonly
Sets the attribute lines.
Instance Method Summary collapse
- #accept(visitor) ⇒ Object
- #backtrace_line(step_name, line) ⇒ Object
- #file_line(line) ⇒ Object
-
#initialize(comment, tags, name, feature_elements) ⇒ Feature
constructor
A new instance of Feature.
- #matches_scenario_names?(scenario_names) ⇒ Boolean
- #scenario_executed(scenario) ⇒ Object
- #step_executed(step) ⇒ Object
- #tagged_with?(tag_names, check_elements = true) ⇒ Boolean
- #to_sexp ⇒ Object
Constructor Details
#initialize(comment, tags, name, feature_elements) ⇒ Feature
Returns a new instance of Feature.
8 9 10 11 12 |
# File 'lib/cucumber/ast/feature.rb', line 8 def initialize(comment, , name, feature_elements) @comment, @tags, @name, @feature_elements = comment, , name, feature_elements feature_elements.each{|feature_element| feature_element.feature = self} @lines = [] end |
Instance Attribute Details
#features=(value) ⇒ Object (writeonly)
Sets the attribute features
6 7 8 |
# File 'lib/cucumber/ast/feature.rb', line 6 def features=(value) @features = value end |
#file ⇒ Object
Returns the value of attribute file.
5 6 7 |
# File 'lib/cucumber/ast/feature.rb', line 5 def file @file end |
#lines=(value) ⇒ Object (writeonly)
Sets the attribute lines
6 7 8 |
# File 'lib/cucumber/ast/feature.rb', line 6 def lines=(value) @lines = value end |
Instance Method Details
#accept(visitor) ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/cucumber/ast/feature.rb', line 23 def accept(visitor) visitor.current_feature_lines = @lines visitor.visit_comment(@comment) visitor.(@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 |
#backtrace_line(step_name, line) ⇒ Object
41 42 43 |
# File 'lib/cucumber/ast/feature.rb', line 41 def backtrace_line(step_name, line) "#{file_line(line)}:in `#{step_name}'" end |
#file_line(line) ⇒ Object
45 46 47 |
# File 'lib/cucumber/ast/feature.rb', line 45 def file_line(line) "#{@file}:#{line}" end |
#matches_scenario_names?(scenario_names) ⇒ Boolean
19 20 21 |
# File 'lib/cucumber/ast/feature.rb', line 19 def matches_scenario_names?(scenario_names) @feature_elements.detect{|e| e.matches_scenario_names?(scenario_names)} end |
#scenario_executed(scenario) ⇒ Object
33 34 35 |
# File 'lib/cucumber/ast/feature.rb', line 33 def scenario_executed(scenario) @features.scenario_executed(scenario) if @features end |
#step_executed(step) ⇒ Object
37 38 39 |
# File 'lib/cucumber/ast/feature.rb', line 37 def step_executed(step) @features.step_executed(step) if @features end |
#tagged_with?(tag_names, check_elements = true) ⇒ Boolean
14 15 16 17 |
# File 'lib/cucumber/ast/feature.rb', line 14 def tagged_with?(tag_names, check_elements=true) @tags.among?(tag_names) || (check_elements && @feature_elements.detect{|e| e.tagged_with?(tag_names)}) end |
#to_sexp ⇒ Object
49 50 51 52 53 54 55 56 57 |
# File 'lib/cucumber/ast/feature.rb', line 49 def to_sexp sexp = [:feature, @name] comment = @comment.to_sexp sexp += [comment] if comment = @tags.to_sexp sexp += if .any? sexp += @feature_elements.map{|e| e.to_sexp} sexp end |