Class: Cucumber::Ast::StepInvocation
- Defined in:
- lib/cucumber/ast/step_invocation.rb
Instance Attribute Summary collapse
-
#background ⇒ Object
writeonly
Sets the attribute background.
-
#exception ⇒ Object
Returns the value of attribute exception.
-
#matched_cells ⇒ Object
readonly
Returns the value of attribute matched_cells.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#step_collection ⇒ Object
writeonly
Sets the attribute step_collection.
Instance Method Summary collapse
- #accept(visitor) ⇒ Object
- #actual_keyword ⇒ Object
- #background? ⇒ Boolean
- #backtrace_line ⇒ Object
- #dom_id ⇒ Object
- #failed(exception, clear_backtrace) ⇒ Object
- #file_colon_line ⇒ Object
- #find_step_match!(step_mother) ⇒ Object
-
#initialize(step, name, multiline_arg, matched_cells) ⇒ StepInvocation
constructor
A new instance of StepInvocation.
- #invoke(step_mother, options) ⇒ Object
- #keyword ⇒ Object
- #matches_lines?(lines) ⇒ Boolean
- #multiline_arg ⇒ Object
- #previous ⇒ Object
- #skip_invoke! ⇒ Object
- #status!(status) ⇒ Object
- #text_length ⇒ Object
- #to_sexp ⇒ Object
Constructor Details
#initialize(step, name, multiline_arg, matched_cells) ⇒ StepInvocation
Returns a new instance of StepInvocation.
8 9 10 11 |
# File 'lib/cucumber/ast/step_invocation.rb', line 8 def initialize(step, name, multiline_arg, matched_cells) @step, @name, @multiline_arg, @matched_cells = step, name, multiline_arg, matched_cells status!(:skipped) end |
Instance Attribute Details
#background=(value) ⇒ Object (writeonly)
Sets the attribute background
4 5 6 |
# File 'lib/cucumber/ast/step_invocation.rb', line 4 def background=(value) @background = value end |
#exception ⇒ Object
Returns the value of attribute exception.
6 7 8 |
# File 'lib/cucumber/ast/step_invocation.rb', line 6 def exception @exception end |
#matched_cells ⇒ Object (readonly)
Returns the value of attribute matched_cells.
5 6 7 |
# File 'lib/cucumber/ast/step_invocation.rb', line 5 def matched_cells @matched_cells end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/cucumber/ast/step_invocation.rb', line 5 def name @name end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
5 6 7 |
# File 'lib/cucumber/ast/step_invocation.rb', line 5 def status @status end |
#step_collection=(value) ⇒ Object (writeonly)
Sets the attribute step_collection
4 5 6 |
# File 'lib/cucumber/ast/step_invocation.rb', line 4 def step_collection=(value) @step_collection = value end |
Instance Method Details
#accept(visitor) ⇒ Object
21 22 23 24 |
# File 'lib/cucumber/ast/step_invocation.rb', line 21 def accept(visitor) invoke(visitor.step_mother, visitor.) @step.visit_step_details(visitor, @step_match, @multiline_arg, @status, @exception, @background) end |
#actual_keyword ⇒ Object
81 82 83 84 85 86 87 |
# File 'lib/cucumber/ast/step_invocation.rb', line 81 def actual_keyword if [Cucumber.keyword_hash['and'], Cucumber.keyword_hash['but']].index(@step.keyword) && previous previous.actual_keyword else keyword end end |
#background? ⇒ Boolean
13 14 15 |
# File 'lib/cucumber/ast/step_invocation.rb', line 13 def background? @background end |
#backtrace_line ⇒ Object
113 114 115 |
# File 'lib/cucumber/ast/step_invocation.rb', line 113 def backtrace_line @step.backtrace_line end |
#dom_id ⇒ Object
109 110 111 |
# File 'lib/cucumber/ast/step_invocation.rb', line 109 def dom_id @step.dom_id end |
#failed(exception, clear_backtrace) ⇒ Object
63 64 65 66 67 |
# File 'lib/cucumber/ast/step_invocation.rb', line 63 def failed(exception, clear_backtrace) @exception = exception @exception.set_backtrace([]) if clear_backtrace @exception.backtrace << @step.backtrace_line unless @step.backtrace_line.nil? end |
#file_colon_line ⇒ Object
105 106 107 |
# File 'lib/cucumber/ast/step_invocation.rb', line 105 def file_colon_line @step.file_colon_line end |
#find_step_match!(step_mother) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/cucumber/ast/step_invocation.rb', line 47 def find_step_match!(step_mother) return if @step_match begin @step_match = step_mother.step_match(@name) rescue Undefined => e failed(e, true) status!(:undefined) @step_match = NoStepMatch.new(@step) rescue Ambiguous => e failed(e, false) status!(:failed) @step_match = NoStepMatch.new(@step) end step_mother.step_visited(self) end |
#invoke(step_mother, options) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/cucumber/ast/step_invocation.rb', line 26 def invoke(step_mother, ) find_step_match!(step_mother) unless @skip_invoke || [:dry_run] || exception || @step_collection.exception @skip_invoke = true begin step_mother.current_world.__cucumber_current_step = self if step_mother.current_world # Nil in Pure Java @step_match.invoke(step_mother.current_world, @multiline_arg) status!(:passed) rescue Pending => e failed(e, false) status!(:pending) rescue Undefined => e failed(e, false) status!(:undefined) rescue Exception => e failed(e, false) status!(:failed) end end end |
#keyword ⇒ Object
97 98 99 |
# File 'lib/cucumber/ast/step_invocation.rb', line 97 def keyword @step.keyword end |
#matches_lines?(lines) ⇒ Boolean
89 90 91 |
# File 'lib/cucumber/ast/step_invocation.rb', line 89 def matches_lines?(lines) @step.matches_lines?(lines) end |
#multiline_arg ⇒ Object
101 102 103 |
# File 'lib/cucumber/ast/step_invocation.rb', line 101 def multiline_arg @step.multiline_arg end |
#previous ⇒ Object
77 78 79 |
# File 'lib/cucumber/ast/step_invocation.rb', line 77 def previous @step_collection.previous_step(self) end |
#skip_invoke! ⇒ Object
17 18 19 |
# File 'lib/cucumber/ast/step_invocation.rb', line 17 def skip_invoke! @skip_invoke = true end |
#status!(status) ⇒ Object
69 70 71 72 73 74 75 |
# File 'lib/cucumber/ast/step_invocation.rb', line 69 def status!(status) @status = status @multiline_arg.status = status if @multiline_arg @matched_cells.each do |cell| cell.status = status end end |
#text_length ⇒ Object
93 94 95 |
# File 'lib/cucumber/ast/step_invocation.rb', line 93 def text_length @step.text_length end |
#to_sexp ⇒ Object
117 118 119 |
# File 'lib/cucumber/ast/step_invocation.rb', line 117 def to_sexp [:step_invocation, @step.line, @step.keyword, @name, (@multiline_arg.nil? ? nil : @multiline_arg.to_sexp)].compact end |