Class: Cucumber::Ast::Step
Instance Attribute Summary collapse
-
#exception ⇒ Object
Returns the value of attribute exception.
-
#feature_element ⇒ Object
Returns the value of attribute feature_element.
-
#keyword ⇒ Object
readonly
Returns the value of attribute keyword.
-
#line ⇒ Object
readonly
Returns the value of attribute line.
-
#multiline_arg ⇒ Object
readonly
Returns the value of attribute multiline_arg.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#options ⇒ Object
writeonly
Sets the attribute options.
-
#step_collection ⇒ Object
writeonly
Sets the attribute step_collection.
Instance Method Summary collapse
- #accept(visitor) ⇒ Object
- #background? ⇒ Boolean
- #backtrace_line ⇒ Object
- #dom_id ⇒ Object
- #file_colon_line ⇒ Object
- #first_match(visitor) ⇒ Object
-
#initialize(line, keyword, name, multiline_arg = nil) ⇒ Step
constructor
A new instance of Step.
- #source_indent ⇒ Object
- #step_invocation ⇒ Object
- #step_invocation_from_cells(cells) ⇒ Object
- #text_length ⇒ Object
- #to_sexp ⇒ Object
- #visit_step_result(visitor, step_match, multiline_arg, status, exception, background) ⇒ Object
Constructor Details
#initialize(line, keyword, name, multiline_arg = nil) ⇒ Step
Returns a new instance of Step.
11 12 13 |
# File 'lib/cucumber/ast/step.rb', line 11 def initialize(line, keyword, name, multiline_arg=nil) @line, @keyword, @name, @multiline_arg = line, keyword, name, multiline_arg end |
Instance Attribute Details
#exception ⇒ Object
Returns the value of attribute exception.
9 10 11 |
# File 'lib/cucumber/ast/step.rb', line 9 def exception @exception end |
#feature_element ⇒ Object
Returns the value of attribute feature_element.
9 10 11 |
# File 'lib/cucumber/ast/step.rb', line 9 def feature_element @feature_element end |
#keyword ⇒ Object (readonly)
Returns the value of attribute keyword.
7 8 9 |
# File 'lib/cucumber/ast/step.rb', line 7 def keyword @keyword end |
#line ⇒ Object (readonly)
Returns the value of attribute line.
7 8 9 |
# File 'lib/cucumber/ast/step.rb', line 7 def line @line end |
#multiline_arg ⇒ Object (readonly)
Returns the value of attribute multiline_arg.
7 8 9 |
# File 'lib/cucumber/ast/step.rb', line 7 def multiline_arg @multiline_arg end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/cucumber/ast/step.rb', line 7 def name @name end |
#options=(value) ⇒ Object (writeonly)
Sets the attribute options
8 9 10 |
# File 'lib/cucumber/ast/step.rb', line 8 def (value) @options = value end |
#step_collection=(value) ⇒ Object (writeonly)
Sets the attribute step_collection
8 9 10 |
# File 'lib/cucumber/ast/step.rb', line 8 def step_collection=(value) @step_collection = value end |
Instance Method Details
#accept(visitor) ⇒ Object
33 34 35 36 37 |
# File 'lib/cucumber/ast/step.rb', line 33 def accept(visitor) # The only time a Step is visited is when it is in a ScenarioOutline. # Otherwise it's always StepInvocation that gest visited instead. visit_step_result(visitor, first_match(visitor), @multiline_arg, :skipped, nil, nil) end |
#background? ⇒ Boolean
15 16 17 |
# File 'lib/cucumber/ast/step.rb', line 15 def background? false end |
#backtrace_line ⇒ Object
67 68 69 |
# File 'lib/cucumber/ast/step.rb', line 67 def backtrace_line @backtrace_line ||= @feature_element.backtrace_line("#{@keyword} #{@name}", @line) unless @feature_element.nil? end |
#dom_id ⇒ Object
75 76 77 |
# File 'lib/cucumber/ast/step.rb', line 75 def dom_id @dom_id ||= file_colon_line.gsub(/\//, '_').gsub(/\./, '_').gsub(/:/, '_') end |
#file_colon_line ⇒ Object
71 72 73 |
# File 'lib/cucumber/ast/step.rb', line 71 def file_colon_line @file_colon_line ||= @feature_element.file_colon_line(@line) unless @feature_element.nil? end |
#first_match(visitor) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/cucumber/ast/step.rb', line 43 def first_match(visitor) # @feature_element is always a ScenarioOutline in this case @feature_element.each_example_row do |cells| argument_hash = cells.to_hash delimited_arguments = delimit_argument_names(argument_hash) name = replace_name_arguments(delimited_arguments) step_match = visitor.step_mother.step_match(name, @name) rescue nil return step_match if step_match end NoStepMatch.new(self) end |
#source_indent ⇒ Object
59 60 61 |
# File 'lib/cucumber/ast/step.rb', line 59 def source_indent @feature_element.source_indent(text_length) end |
#step_invocation ⇒ Object
19 20 21 |
# File 'lib/cucumber/ast/step.rb', line 19 def step_invocation StepInvocation.new(self, @name, @multiline_arg, []) end |
#step_invocation_from_cells(cells) ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/cucumber/ast/step.rb', line 23 def step_invocation_from_cells(cells) matched_cells = matched_cells(cells) delimited_arguments = delimit_argument_names(cells.to_hash) name = replace_name_arguments(delimited_arguments) multiline_arg = @multiline_arg.nil? ? nil : @multiline_arg.arguments_replaced(delimited_arguments) StepInvocation.new(self, name, multiline_arg, matched_cells) end |
#text_length ⇒ Object
63 64 65 |
# File 'lib/cucumber/ast/step.rb', line 63 def text_length @keyword.jlength + @name.jlength + 2 # Add 2 because steps get indented 2 more than scenarios end |
#to_sexp ⇒ Object
55 56 57 |
# File 'lib/cucumber/ast/step.rb', line 55 def to_sexp [:step, @line, @keyword, @name, (@multiline_arg.nil? ? nil : @multiline_arg.to_sexp)].compact end |
#visit_step_result(visitor, step_match, multiline_arg, status, exception, background) ⇒ Object
39 40 41 |
# File 'lib/cucumber/ast/step.rb', line 39 def visit_step_result(visitor, step_match, multiline_arg, status, exception, background) visitor.visit_step_result(@keyword, step_match, @multiline_arg, status, exception, source_indent, background) end |