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, background = nil) ⇒ 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, background = nil) ⇒ Feature
Returns a new instance of Feature.
8 9 10 11 12 13 14 15 16 |
# File 'lib/cucumber/ast/feature.rb', line 8 def initialize(comment, , name, feature_elements, background = nil) @comment, , @name, @feature_elements, @background = comment, , name, feature_elements, background feature_elements.each do |feature_element| feature_element.feature = self feature_element.background = background if background end background.feature = self if background @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
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/cucumber/ast/feature.rb', line 27 def accept(visitor) visitor.current_feature_lines = @lines visitor.visit_comment(@comment) visitor.() 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
46 47 48 |
# File 'lib/cucumber/ast/feature.rb', line 46 def backtrace_line(step_name, line) "#{file_line(line)}:in `#{step_name}'" end |
#file_line(line) ⇒ Object
50 51 52 |
# File 'lib/cucumber/ast/feature.rb', line 50 def file_line(line) "#{@file}:#{line}" end |
#matches_scenario_names?(scenario_names) ⇒ Boolean
23 24 25 |
# File 'lib/cucumber/ast/feature.rb', line 23 def matches_scenario_names?(scenario_names) @feature_elements.detect{|e| e.matches_scenario_names?(scenario_names)} end |
#scenario_executed(scenario) ⇒ Object
38 39 40 |
# File 'lib/cucumber/ast/feature.rb', line 38 def scenario_executed(scenario) @features.scenario_executed(scenario) if @features end |
#step_executed(step) ⇒ Object
42 43 44 |
# File 'lib/cucumber/ast/feature.rb', line 42 def step_executed(step) @features.step_executed(step) if @features end |
#tagged_with?(tag_names, check_elements = true) ⇒ Boolean
18 19 20 21 |
# File 'lib/cucumber/ast/feature.rb', line 18 def tagged_with?(tag_names, check_elements=true) .among?(tag_names) || (check_elements && @feature_elements.detect{|e| e.tagged_with?(tag_names)}) end |
#to_sexp ⇒ Object
54 55 56 57 58 59 60 61 62 63 |
# File 'lib/cucumber/ast/feature.rb', line 54 def to_sexp sexp = [:feature, @name] comment = @comment.to_sexp sexp += [comment] if comment = .to_sexp sexp += if .any? sexp += [@background.to_sexp] if @background sexp += @feature_elements.map{|e| e.to_sexp} sexp end |