Class: Spinach::Runner::ScenarioRunner
- Inherits:
-
Object
- Object
- Spinach::Runner::ScenarioRunner
- Defined in:
- lib/spinach/runner/scenario_runner.rb
Overview
A Scenario Runner handles a particular scenario run.
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#feature_name ⇒ Object
readonly
Returns the value of attribute feature_name.
Instance Method Summary collapse
-
#feature_steps ⇒ FeatureSteps
The feature object used to run this scenario.
-
#initialize(feature_name, data) ⇒ ScenarioRunner
constructor
A new instance of ScenarioRunner.
-
#run ⇒ True, False
Runs this scenario.
- #steps ⇒ Object
Constructor Details
#initialize(feature_name, data) ⇒ ScenarioRunner
Returns a new instance of ScenarioRunner.
15 16 17 18 |
# File 'lib/spinach/runner/scenario_runner.rb', line 15 def initialize(feature_name, data) @feature_name = feature_name @data = data end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
6 7 8 |
# File 'lib/spinach/runner/scenario_runner.rb', line 6 def data @data end |
#feature_name ⇒ Object (readonly)
Returns the value of attribute feature_name.
6 7 8 |
# File 'lib/spinach/runner/scenario_runner.rb', line 6 def feature_name @feature_name end |
Instance Method Details
#feature_steps ⇒ FeatureSteps
Returns The feature object used to run this scenario.
28 29 30 |
# File 'lib/spinach/runner/scenario_runner.rb', line 28 def feature_steps @feature_steps ||= Spinach.find_feature_steps(feature_name).new end |
#run ⇒ True, False
Runs this scenario
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/spinach/runner/scenario_runner.rb', line 35 def run Spinach.hooks.run_before_scenario data steps.each do |step| Spinach.hooks.run_before_step step unless @exception begin step_location = feature_steps.execute_step(step['name']) Spinach.hooks.run_on_successful_step step, step_location rescue *Spinach.config[:failure_exceptions] => e @exception = e Spinach.hooks.run_on_failed_step step, @exception, step_location rescue Spinach::StepNotDefinedException => e @exception = e Spinach.hooks.run_on_undefined_step step, @exception rescue Exception => e @exception = e Spinach.hooks.run_on_error_step step, @exception, step_location end else Spinach.hooks.run_on_skipped_step step end Spinach.hooks.run_after_step step end Spinach.hooks.run_after_scenario data !@exception end |
#steps ⇒ Object
20 21 22 |
# File 'lib/spinach/runner/scenario_runner.rb', line 20 def steps @steps ||= data['steps'] end |