Class: Cucumber::Ast::StepInvocation
- Includes:
- Gherkin::Rubify
- Defined in:
- lib/cucumber/ast/step_invocation.rb
Overview
:nodoc:
Constant Summary collapse
- BACKTRACE_FILTER_PATTERNS =
[ /vendor\/rails|lib\/cucumber|bin\/cucumber:|lib\/rspec|gems\// ]
- SEVERITY =
[:passed, :undefined, :pending, :skipped, :failed]
- PWD_PATTERN =
/#{Regexp.escape(Dir.pwd)}\//m
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.
-
#reported_exception ⇒ Object
readonly
Returns the value of attribute reported_exception.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#step_collection ⇒ Object
writeonly
Sets the attribute step_collection.
Class Method Summary collapse
Instance Method Summary collapse
- #accept(visitor) ⇒ Object
- #actual_keyword ⇒ Object
- #background? ⇒ Boolean
- #backtrace_line ⇒ Object
- #dom_id ⇒ Object
- #failed(configuration, e, clear_backtrace) ⇒ Object
- #file_colon_line ⇒ Object
- #filter_backtrace(e) ⇒ Object
- #find_step_match!(step_mother, configuration) ⇒ Object
- #gherkin_statement ⇒ Object
-
#initialize(step, name, multiline_arg, matched_cells) ⇒ StepInvocation
constructor
A new instance of StepInvocation.
- #invoke(step_mother, configuration) ⇒ Object
- #keyword ⇒ Object
- #language ⇒ Object
- #multiline_arg ⇒ Object
- #previous ⇒ Object
- #skip_invoke! ⇒ Object
- #source_indent ⇒ Object
- #status!(status) ⇒ Object
- #text_length ⇒ Object
- #to_sexp ⇒ Object
- #visit_step_result(visitor) ⇒ Object
Constructor Details
#initialize(step, name, multiline_arg, matched_cells) ⇒ StepInvocation
Returns a new instance of StepInvocation.
26 27 28 29 30 |
# File 'lib/cucumber/ast/step_invocation.rb', line 26 def initialize(step, name, multiline_arg, matched_cells) @step, @name, @multiline_arg, @matched_cells = step, name, multiline_arg, matched_cells status!(:skipped) @skip_invoke = @exception = @step_match = @different_table = @reported_exception = @background = nil end |
Instance Attribute Details
#background=(value) ⇒ Object (writeonly)
Sets the attribute background
15 16 17 |
# File 'lib/cucumber/ast/step_invocation.rb', line 15 def background=(value) @background = value end |
#exception ⇒ Object
Returns the value of attribute exception.
17 18 19 |
# File 'lib/cucumber/ast/step_invocation.rb', line 17 def exception @exception end |
#matched_cells ⇒ Object (readonly)
Returns the value of attribute matched_cells.
16 17 18 |
# File 'lib/cucumber/ast/step_invocation.rb', line 16 def matched_cells @matched_cells end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
16 17 18 |
# File 'lib/cucumber/ast/step_invocation.rb', line 16 def name @name end |
#reported_exception ⇒ Object (readonly)
Returns the value of attribute reported_exception.
16 17 18 |
# File 'lib/cucumber/ast/step_invocation.rb', line 16 def reported_exception @reported_exception end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
16 17 18 |
# File 'lib/cucumber/ast/step_invocation.rb', line 16 def status @status end |
#step_collection=(value) ⇒ Object (writeonly)
Sets the attribute step_collection
15 16 17 |
# File 'lib/cucumber/ast/step_invocation.rb', line 15 def step_collection=(value) @step_collection = value end |
Class Method Details
Instance Method Details
#accept(visitor) ⇒ Object
40 41 42 43 44 |
# File 'lib/cucumber/ast/step_invocation.rb', line 40 def accept(visitor) return if Cucumber.wants_to_quit invoke(visitor.step_mother, visitor.configuration) visit_step_result(visitor) end |
#actual_keyword ⇒ Object
149 150 151 152 153 154 155 156 |
# File 'lib/cucumber/ast/step_invocation.rb', line 149 def actual_keyword repeat_keywords = rubify([language.keywords('but'), language.keywords('and')]).flatten.uniq.reject{|kw| kw == '* '} if repeat_keywords.index(@step.keyword) && previous previous.actual_keyword else keyword == '* ' ? language.code_keywords.first : keyword end end |
#background? ⇒ Boolean
32 33 34 |
# File 'lib/cucumber/ast/step_invocation.rb', line 32 def background? @background end |
#backtrace_line ⇒ Object
182 183 184 |
# File 'lib/cucumber/ast/step_invocation.rb', line 182 def backtrace_line @step.backtrace_line end |
#dom_id ⇒ Object
178 179 180 |
# File 'lib/cucumber/ast/step_invocation.rb', line 178 def dom_id @step.dom_id end |
#failed(configuration, e, clear_backtrace) ⇒ Object
99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/cucumber/ast/step_invocation.rb', line 99 def failed(configuration, e, clear_backtrace) e = filter_backtrace(e) e.set_backtrace([]) if clear_backtrace e.backtrace << @step.backtrace_line unless @step.backtrace_line.nil? @exception = e if(configuration.strict? || !(Undefined === e) || e.nested?) @reported_exception = e else @reported_exception = nil end end |
#file_colon_line ⇒ Object
174 175 176 |
# File 'lib/cucumber/ast/step_invocation.rb', line 174 def file_colon_line @step.file_colon_line end |
#filter_backtrace(e) ⇒ Object
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
# File 'lib/cucumber/ast/step_invocation.rb', line 113 def filter_backtrace(e) return e if Cucumber.use_full_backtrace (e.backtrace || []).each{|line| line.gsub!(PWD_PATTERN, "./")} filtered = (e.backtrace || []).reject do |line| BACKTRACE_FILTER_PATTERNS.detect { |p| line =~ p } end if Cucumber::JRUBY && e.class.name == 'NativeException' # JRuby's NativeException ignores #set_backtrace. # We're fixing it. e.instance_eval do def set_backtrace(backtrace) @backtrace = backtrace end def backtrace @backtrace end end end e.set_backtrace(filtered) e end |
#find_step_match!(step_mother, configuration) ⇒ Object
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/cucumber/ast/step_invocation.rb', line 83 def find_step_match!(step_mother, configuration) return if @step_match begin @step_match = step_mother.step_match(@name) rescue Undefined => e failed(configuration, e, true) status!(:undefined) @step_match = NoStepMatch.new(@step, @name) rescue Ambiguous => e failed(configuration, e, false) status!(:failed) @step_match = NoStepMatch.new(@step, @name) end step_mother.step_visited(self) end |
#gherkin_statement ⇒ Object
190 191 192 |
# File 'lib/cucumber/ast/step_invocation.rb', line 190 def gherkin_statement @step.gherkin_statement end |
#invoke(step_mother, configuration) ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/cucumber/ast/step_invocation.rb', line 58 def invoke(step_mother, configuration) find_step_match!(step_mother, configuration) unless @skip_invoke || configuration.dry_run? || @exception || @step_collection.exception @skip_invoke = true begin @step_match.invoke(@multiline_arg) step_mother.after_step status!(:passed) rescue Pending => e failed(configuration, e, false) status!(:pending) rescue Undefined => e failed(configuration, e, false) status!(:undefined) rescue Cucumber::Ast::Table::Different => e @different_table = e.table failed(configuration, e, false) status!(:failed) rescue Exception => e failed(configuration, e, false) status!(:failed) end end end |
#keyword ⇒ Object
166 167 168 |
# File 'lib/cucumber/ast/step_invocation.rb', line 166 def keyword @step.keyword end |
#language ⇒ Object
186 187 188 |
# File 'lib/cucumber/ast/step_invocation.rb', line 186 def language @step.language end |
#multiline_arg ⇒ Object
170 171 172 |
# File 'lib/cucumber/ast/step_invocation.rb', line 170 def multiline_arg @step.multiline_arg end |
#previous ⇒ Object
145 146 147 |
# File 'lib/cucumber/ast/step_invocation.rb', line 145 def previous @step_collection.previous_step(self) end |
#skip_invoke! ⇒ Object
36 37 38 |
# File 'lib/cucumber/ast/step_invocation.rb', line 36 def skip_invoke! @skip_invoke = true end |
#source_indent ⇒ Object
158 159 160 |
# File 'lib/cucumber/ast/step_invocation.rb', line 158 def source_indent @step.feature_element.source_indent(text_length) end |
#status!(status) ⇒ Object
138 139 140 141 142 143 |
# File 'lib/cucumber/ast/step_invocation.rb', line 138 def status!(status) @status = status @matched_cells.each do |cell| cell.status = status end end |
#text_length ⇒ Object
162 163 164 |
# File 'lib/cucumber/ast/step_invocation.rb', line 162 def text_length @step.text_length(@name) end |
#to_sexp ⇒ Object
194 195 196 |
# File 'lib/cucumber/ast/step_invocation.rb', line 194 def to_sexp [:step_invocation, @step.line, @step.keyword, @name, (@multiline_arg.nil? ? nil : @multiline_arg.to_sexp)].compact end |
#visit_step_result(visitor) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/cucumber/ast/step_invocation.rb', line 46 def visit_step_result(visitor) visitor.visit_step_result( keyword, @step_match, (@different_table || @multiline_arg), @status, @reported_exception, source_indent, @background ) end |