Class: Cucumber::Ast::Step
Instance Attribute Summary collapse
-
#exception ⇒ Object
Returns the value of attribute exception.
-
#keyword ⇒ Object
readonly
Returns the value of attribute keyword.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#options ⇒ Object
writeonly
Sets the attribute options.
-
#previous ⇒ Object
writeonly
Sets the attribute previous.
-
#scenario ⇒ Object
Returns the value of attribute scenario.
-
#status ⇒ Object
Returns the value of attribute status.
-
#world ⇒ Object
writeonly
Sets the attribute world.
Instance Method Summary collapse
- #accept(visitor) ⇒ Object
- #actual_keyword ⇒ Object
- #at_lines?(lines) ⇒ Boolean
- #backtrace_line ⇒ Object
- #execute_with_arguments(argument_hash, world, previous, visitor, row_line) ⇒ Object
- #file_line ⇒ Object
-
#initialize(line, keyword, name, *multiline_args) ⇒ Step
constructor
A new instance of Step.
- #source_indent ⇒ Object
- #text_length ⇒ Object
- #to_sexp ⇒ Object
Constructor Details
#initialize(line, keyword, name, *multiline_args) ⇒ Step
Returns a new instance of Step.
11 12 13 |
# File 'lib/cucumber/ast/step.rb', line 11 def initialize(line, keyword, name, *multiline_args) @line, @keyword, @name, @multiline_args = line, keyword, name, multiline_args 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 |
#keyword ⇒ Object (readonly)
Returns the value of attribute keyword.
7 8 9 |
# File 'lib/cucumber/ast/step.rb', line 7 def keyword @keyword 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 |
#previous=(value) ⇒ Object (writeonly)
Sets the attribute previous
8 9 10 |
# File 'lib/cucumber/ast/step.rb', line 8 def previous=(value) @previous = value end |
#scenario ⇒ Object
Returns the value of attribute scenario.
9 10 11 |
# File 'lib/cucumber/ast/step.rb', line 9 def scenario @scenario end |
#status ⇒ Object
Returns the value of attribute status.
9 10 11 |
# File 'lib/cucumber/ast/step.rb', line 9 def status @status end |
#world=(value) ⇒ Object (writeonly)
Sets the attribute world
8 9 10 |
# File 'lib/cucumber/ast/step.rb', line 8 def world=(value) @world = value end |
Instance Method Details
#accept(visitor) ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'lib/cucumber/ast/step.rb', line 23 def accept(visitor) execute(visitor) visitor.visit_step_name(@keyword, @name, @status, @step_definition, source_indent) @multiline_args.each do |multiline_arg| visitor.visit_multiline_arg(multiline_arg, @status) end @exception end |
#actual_keyword ⇒ Object
56 57 58 59 60 61 62 |
# File 'lib/cucumber/ast/step.rb', line 56 def actual_keyword if [Cucumber.keyword_hash['and'], Cucumber.keyword_hash['but']].index(@keyword) && previous_step previous_step.actual_keyword else @keyword end end |
#at_lines?(lines) ⇒ Boolean
36 37 38 |
# File 'lib/cucumber/ast/step.rb', line 36 def at_lines?(lines) lines.empty? || lines.index(@line) || @multiline_args.detect{|a| a.at_lines?(lines)} end |
#backtrace_line ⇒ Object
48 49 50 |
# File 'lib/cucumber/ast/step.rb', line 48 def backtrace_line @backtrace_line ||= @scenario.backtrace_line("#{@keyword} #{@name}", @line) unless @scenario.nil? end |
#execute_with_arguments(argument_hash, world, previous, visitor, row_line) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/cucumber/ast/step.rb', line 15 def execute_with_arguments(argument_hash, world, previous, visitor, row_line) delimited_arguments = delimit_argument_names(argument_hash) name = replace_name_arguments(delimited_arguments) multiline_args = replace_multiline_args_arguments(delimited_arguments) execute_twin(world, previous, visitor, row_line, name, *multiline_args) end |
#file_line ⇒ Object
52 53 54 |
# File 'lib/cucumber/ast/step.rb', line 52 def file_line @file_line ||= @scenario.file_line(@line) unless @scenario.nil? end |
#source_indent ⇒ Object
40 41 42 |
# File 'lib/cucumber/ast/step.rb', line 40 def source_indent @scenario.source_indent(text_length) end |
#text_length ⇒ Object
44 45 46 |
# File 'lib/cucumber/ast/step.rb', line 44 def text_length @keyword.jlength + @name.jlength + 2 # Add 2 because steps get indented 2 more than scenarios end |
#to_sexp ⇒ Object
32 33 34 |
# File 'lib/cucumber/ast/step.rb', line 32 def to_sexp [:step, @line, @keyword, @name, *@multiline_args.map{|arg| arg.to_sexp}] end |