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_as_new(world, previous, visitor, row_line) ⇒ Object
- #execute_with_arguments(argument_hash, world, previous, visitor, row_line) ⇒ Object
- #file_line ⇒ Object
- #find_first_name_and_step_definition_from_examples(visitor) ⇒ 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
27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/cucumber/ast/step.rb', line 27 def accept(visitor) execute(visitor) if @status == :outline step_definition = find_first_name_and_step_definition_from_examples(visitor) else step_definition = @step_definition end 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
78 79 80 81 82 83 84 |
# File 'lib/cucumber/ast/step.rb', line 78 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
58 59 60 |
# File 'lib/cucumber/ast/step.rb', line 58 def at_lines?(lines) lines.empty? || lines.index(@line) || @multiline_args.detect{|a| a.at_lines?(lines)} end |
#backtrace_line ⇒ Object
70 71 72 |
# File 'lib/cucumber/ast/step.rb', line 70 def backtrace_line @backtrace_line ||= @scenario.backtrace_line("#{@keyword} #{@name}", @line) unless @scenario.nil? end |
#execute_as_new(world, previous, visitor, row_line) ⇒ Object
23 24 25 |
# File 'lib/cucumber/ast/step.rb', line 23 def execute_as_new(world, previous, visitor, row_line) execute_twin(world, previous, visitor, row_line, @name, *@multiline_args) 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
74 75 76 |
# File 'lib/cucumber/ast/step.rb', line 74 def file_line @file_line ||= @scenario.file_line(@line) unless @scenario.nil? end |
#find_first_name_and_step_definition_from_examples(visitor) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/cucumber/ast/step.rb', line 42 def find_first_name_and_step_definition_from_examples(visitor) # @scenario is always a ScenarioOutline in this case @scenario.each_example_row do |cells| argument_hash = cells.to_hash delimited_arguments = delimit_argument_names(argument_hash) name = replace_name_arguments(delimited_arguments) step_definition = visitor.step_definition(name) rescue nil return step_definition if step_definition end nil end |
#source_indent ⇒ Object
62 63 64 |
# File 'lib/cucumber/ast/step.rb', line 62 def source_indent @scenario.source_indent(text_length) end |
#text_length ⇒ Object
66 67 68 |
# File 'lib/cucumber/ast/step.rb', line 66 def text_length @keyword.jlength + @name.jlength + 2 # Add 2 because steps get indented 2 more than scenarios end |
#to_sexp ⇒ Object
54 55 56 |
# File 'lib/cucumber/ast/step.rb', line 54 def to_sexp [:step, @line, @keyword, @name, *@multiline_args.map{|arg| arg.to_sexp}] end |