forked from cucumber/cucumber-ruby
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dbe40ef
commit 495d537
Showing
9 changed files
with
123 additions
and
121 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
module Cucumber | ||
module Ast | ||
class StepInvocation | ||
attr_writer :step_collection, :background | ||
attr_reader :name, :matched_cells, :status | ||
attr_accessor :exception | ||
|
||
def initialize(step, name, multiline_arg, matched_cells) | ||
@step, @name, @multiline_arg, @matched_cells = step, name, multiline_arg, matched_cells | ||
status!(:skipped) | ||
end | ||
|
||
def background? | ||
@background | ||
end | ||
|
||
def skip_invoke! | ||
@skip_invoke = true | ||
end | ||
|
||
def accept(visitor) | ||
invoke(visitor.step_mother, visitor.options) | ||
@step.visit_step_details(visitor, @step_match, @multiline_arg, @status, @exception, @background) | ||
end | ||
|
||
def invoke(step_mother, options) | ||
find_step_match!(step_mother) | ||
unless @skip_invoke || options[:dry_run] || exception || previous.exception | ||
@skip_invoke = true | ||
begin | ||
step_mother.current_world.__cucumber_current_step = self | ||
@step.invoke(@step_match, step_mother.current_world) | ||
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 | ||
|
||
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 | ||
|
||
def failed(exception, clear_backtrace) | ||
@exception = exception | ||
@exception.set_backtrace([]) if clear_backtrace | ||
@exception.backtrace << @step.backtrace_line unless @step.backtrace_line.nil? | ||
end | ||
|
||
def status!(status) | ||
@status = status | ||
@multiline_arg.status = status if @multiline_arg | ||
@matched_cells.each do |cell| | ||
cell.status = status | ||
end | ||
end | ||
|
||
def previous | ||
@step_collection.previous_step(self) | ||
end | ||
|
||
def actual_keyword | ||
if [Cucumber.keyword_hash['and'], Cucumber.keyword_hash['but']].index(@keyword) && previous | ||
previous.actual_keyword | ||
else | ||
@step.keyword | ||
end | ||
end | ||
|
||
def matches_lines?(lines) | ||
@step.matches_lines?(lines) | ||
end | ||
|
||
def text_length | ||
@step.text_length | ||
end | ||
|
||
def to_sexp | ||
[:step_invocation, @step.line, @step.keyword, @name, (@multiline_arg.nil? ? nil : @multiline_arg.to_sexp)].compact | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters