Module: Cucumber::Ast::FeatureElement
- Included in:
- Background, Scenario, ScenarioOutline
- Defined in:
- lib/cucumber/ast/feature_element.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#feature ⇒ Object
Returns the value of attribute feature.
Instance Method Summary collapse
- #accept_hook?(hook) ⇒ Boolean
- #attach_steps(steps) ⇒ Object
- #backtrace_line(name = "#{@keyword} #{@name}", line = @line) ⇒ Object
- #file_colon_line(line = @line) ⇒ Object
- #first_line_length ⇒ Object
- #language ⇒ Object
- #matches_scenario_names?(scenario_name_regexps) ⇒ Boolean
- #max_line_length ⇒ Object
- #name_line_lengths ⇒ Object
- #source_indent(text_length) ⇒ Object
- #source_tag_names ⇒ Object
- #tagged_with?(tag) ⇒ Boolean
- #text_length ⇒ Object
Instance Attribute Details
#feature ⇒ Object
Returns the value of attribute feature.
7 8 9 |
# File 'lib/cucumber/ast/feature_element.rb', line 7 def feature @feature end |
Instance Method Details
#accept_hook?(hook) ⇒ Boolean
51 52 53 |
# File 'lib/cucumber/ast/feature_element.rb', line 51 def accept_hook?(hook) TagExpression.parse(hook.tag_expressions).eval(source_tag_names) end |
#attach_steps(steps) ⇒ Object
9 10 11 |
# File 'lib/cucumber/ast/feature_element.rb', line 9 def attach_steps(steps) steps.each {|step| step.feature_element = self} end |
#backtrace_line(name = "#{@keyword} #{@name}", line = @line) ⇒ Object
39 40 41 |
# File 'lib/cucumber/ast/feature_element.rb', line 39 def backtrace_line(name = "#{@keyword} #{@name}", line = @line) @feature.backtrace_line(name, line) if @feature end |
#file_colon_line(line = @line) ⇒ Object
13 14 15 |
# File 'lib/cucumber/ast/feature_element.rb', line 13 def file_colon_line(line = @line) @feature.file_colon_line(line) if @feature end |
#first_line_length ⇒ Object
21 22 23 |
# File 'lib/cucumber/ast/feature_element.rb', line 21 def first_line_length name_line_lengths[0] end |
#language ⇒ Object
63 64 65 |
# File 'lib/cucumber/ast/feature_element.rb', line 63 def language @feature.language if @feature end |
#matches_scenario_names?(scenario_name_regexps) ⇒ Boolean
35 36 37 |
# File 'lib/cucumber/ast/feature_element.rb', line 35 def matches_scenario_names?(scenario_name_regexps) scenario_name_regexps.detect{|name| name =~ @name} end |
#max_line_length ⇒ Object
47 48 49 |
# File 'lib/cucumber/ast/feature_element.rb', line 47 def max_line_length @steps.max_line_length(self) end |
#name_line_lengths ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'lib/cucumber/ast/feature_element.rb', line 25 def name_line_lengths if @name.strip.empty? [@keyword.jlength] else @name.split("\n").enum_for(:each_with_index).map do |line, line_number| line_number == 0 ? @keyword.jlength + line.jlength : line.jlength + Ast::Step::INDENT - 1 # We -1 as names which are not keyword lines are missing a space between keyword and name end end end |
#source_indent(text_length) ⇒ Object
43 44 45 |
# File 'lib/cucumber/ast/feature_element.rb', line 43 def source_indent(text_length) max_line_length - text_length end |
#source_tag_names ⇒ Object
55 56 57 |
# File 'lib/cucumber/ast/feature_element.rb', line 55 def source_tag_names (@tags.tag_names + (@feature ? @feature.source_tag_names : [])).uniq end |
#tagged_with?(tag) ⇒ Boolean
59 60 61 |
# File 'lib/cucumber/ast/feature_element.rb', line 59 def tagged_with?(tag) source_tag_names.index(tag) end |
#text_length ⇒ Object
17 18 19 |
# File 'lib/cucumber/ast/feature_element.rb', line 17 def text_length name_line_lengths.max end |