Module: Cucumber::Ast::HasSteps
- Included in:
- Background, Scenario, ScenarioOutline
- Defined in:
- lib/cucumber/ast/has_steps.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#gherkin_statement(statement = nil) ⇒ Object
readonly
Returns the value of attribute gherkin_statement.
-
#raw_steps ⇒ Object
readonly
Returns the value of attribute raw_steps.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Instance Method Summary collapse
- #accept_hook?(hook) ⇒ Boolean
- #attach_steps(steps) ⇒ Object
- #backtrace_line(step_name = "#{@keyword}: #{name}", line = self.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
- #source_tags ⇒ Object
- #text_length ⇒ Object
Instance Attribute Details
#description ⇒ Object (readonly)
Returns the value of attribute description.
7 8 9 |
# File 'lib/cucumber/ast/has_steps.rb', line 7 def description @description end |
#gherkin_statement(statement = nil) ⇒ Object (readonly)
Returns the value of attribute gherkin_statement.
7 8 9 |
# File 'lib/cucumber/ast/has_steps.rb', line 7 def gherkin_statement @gherkin_statement end |
#raw_steps ⇒ Object (readonly)
Returns the value of attribute raw_steps.
7 8 9 |
# File 'lib/cucumber/ast/has_steps.rb', line 7 def raw_steps @raw_steps end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
7 8 9 |
# File 'lib/cucumber/ast/has_steps.rb', line 7 def title @title end |
Instance Method Details
#accept_hook?(hook) ⇒ Boolean
56 57 58 |
# File 'lib/cucumber/ast/has_steps.rb', line 56 def accept_hook?(hook) Gherkin::TagExpression.new(hook.tag_expressions).evaluate() end |
#attach_steps(steps) ⇒ Object
12 13 14 15 16 |
# File 'lib/cucumber/ast/has_steps.rb', line 12 def attach_steps(steps) steps.each do |step| step.feature_element = self end end |
#backtrace_line(step_name = "#{@keyword}: #{name}", line = self.line) ⇒ Object
44 45 46 |
# File 'lib/cucumber/ast/has_steps.rb', line 44 def backtrace_line(step_name = "#{@keyword}: #{name}", line = self.line) "#{location.on_line(line)}:in `#{step_name}'" end |
#first_line_length ⇒ Object
18 19 20 |
# File 'lib/cucumber/ast/has_steps.rb', line 18 def first_line_length name_line_lengths[0] end |
#language ⇒ Object
68 69 70 |
# File 'lib/cucumber/ast/has_steps.rb', line 68 def language @language || raise("Language is required for a #{self.class}") end |
#matches_scenario_names?(scenario_name_regexps) ⇒ Boolean
40 41 42 |
# File 'lib/cucumber/ast/has_steps.rb', line 40 def matches_scenario_names?(scenario_name_regexps) scenario_name_regexps.detect{|n| n =~ name} end |
#max_line_length ⇒ Object
52 53 54 |
# File 'lib/cucumber/ast/has_steps.rb', line 52 def max_line_length steps.max_line_length(self) end |
#name_line_lengths ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/cucumber/ast/has_steps.rb', line 26 def name_line_lengths if name.strip.empty? [Ast::Step::INDENT + @keyword.unpack('U*').length + ': '.length] else name.split("\n").enum_for(:each_with_index).map do |line, line_number| if line_number == 0 Ast::Step::INDENT + @keyword.unpack('U*').length + ': '.length + line.unpack('U*').length else Ast::Step::INDENT + Ast::Step::INDENT + line.unpack('U*').length end end end end |
#source_indent(text_length) ⇒ Object
48 49 50 |
# File 'lib/cucumber/ast/has_steps.rb', line 48 def source_indent(text_length) max_line_length - text_length end |
#source_tag_names ⇒ Object
60 61 62 |
# File 'lib/cucumber/ast/has_steps.rb', line 60 def source_tag_names .map { |tag| tag.name } end |
#source_tags ⇒ Object
64 65 66 |
# File 'lib/cucumber/ast/has_steps.rb', line 64 def @tags..to_a + ..to_a end |
#text_length ⇒ Object
22 23 24 |
# File 'lib/cucumber/ast/has_steps.rb', line 22 def text_length name_line_lengths.max end |