-
Notifications
You must be signed in to change notification settings - Fork 69
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
Showing
3 changed files
with
95 additions
and
58 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
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,21 @@ | |||
module Spinach | |||
class Runner | |||
class ScenarioRunnerMutex | |||
def initialize | |||
@running = false | |||
end | |||
|
|||
def deactivate | |||
@running = false | |||
end | |||
|
|||
def activate | |||
@running = true | |||
end | |||
|
|||
def active? | |||
!!@running | |||
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
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,56 @@ | |||
module Spinach | |||
class Runner | |||
class StepRunner | |||
def initialize(step, context) | |||
@step = step | |||
@exception = false | |||
@context = context | |||
end | |||
|
|||
def run(previous_step_success) | |||
hooks.run_before_step @step | |||
execute unless skip?(previous_step_success) | |||
hooks.run_after_step @step | |||
end | |||
|
|||
def skip?(previous_step_success) | |||
unless previous_step_success | |||
hooks.run_on_skipped_step @step | |||
end | |||
!previous_step_success | |||
end | |||
|
|||
# Runs a particular step. | |||
# | |||
# @param [Gherkin::AST::Step] step | |||
# The step to be run. | |||
# | |||
# @api semipublic | |||
def execute | |||
@context.execute(@step) | |||
hooks.run_on_successful_step @step, location | |||
rescue *Spinach.config[:failure_exceptions] => exception | |||
@exception = exception | |||
hooks.run_on_failed_step @step, @exception, location | |||
rescue Spinach::StepNotDefinedException => exception | |||
@exception = exception | |||
hooks.run_on_undefined_step @step, @exception | |||
rescue Exception => exception | |||
@exception = exception | |||
hooks.run_on_error_step @step, @exception, location | |||
end | |||
|
|||
def hooks | |||
Spinach.hooks | |||
end | |||
|
|||
def success? | |||
!@exception | |||
end | |||
|
|||
def location | |||
@context.step_location_for(@step.name) | |||
end | |||
end | |||
end | |||
end |