Class: Spinach::Runner::Scenario
- Inherits:
-
Object
- Object
- Spinach::Runner::Scenario
- Includes:
- Hooks
- Defined in:
- lib/spinach/runner/scenario.rb
Overview
A Scenario Runner handles a particular scenario run.
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#feature ⇒ Object
readonly
Returns the value of attribute feature.
-
#feature_name ⇒ Object
readonly
Returns the value of attribute feature_name.
Instance Method Summary collapse
-
#initialize(feature_name, feature, data) ⇒ Scenario
constructor
A new instance of Scenario.
-
#run ⇒ True, False
Runs this scenario.
- #steps ⇒ Object
Constructor Details
#initialize(feature_name, feature, data) ⇒ Scenario
Returns a new instance of Scenario.
27 28 29 30 31 |
# File 'lib/spinach/runner/scenario.rb', line 27 def initialize(feature_name, feature, data) @feature_name = feature_name @data = data @feature = feature end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
8 9 10 |
# File 'lib/spinach/runner/scenario.rb', line 8 def data @data end |
#feature ⇒ Object (readonly)
Returns the value of attribute feature.
8 9 10 |
# File 'lib/spinach/runner/scenario.rb', line 8 def feature @feature end |
#feature_name ⇒ Object (readonly)
Returns the value of attribute feature_name.
8 9 10 |
# File 'lib/spinach/runner/scenario.rb', line 8 def feature_name @feature_name end |
Instance Method Details
#run ⇒ True, False
Runs this scenario
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/spinach/runner/scenario.rb', line 40 def run run_hook :before_run, data feature.run_hook :before_scenario, data steps.each do |step| feature.run_hook :before_step, step unless @exception begin step_location = feature.execute_step(step['name']) run_hook :on_successful_step, step, step_location rescue *Spinach.config[:failure_exceptions] => e @exception = e run_hook :on_failed_step, step, @exception, step_location rescue Spinach::StepNotDefinedException => e @exception = e run_hook :on_undefined_step, step, @exception rescue Exception => e @exception = e run_hook :on_error_step, step, @exception, step_location end else run_hook :on_skipped_step, step end feature.run_hook :after_step, step end feature.run_hook :after_scenario, data run_hook :after_run, data !@exception end |
#steps ⇒ Object
33 34 35 |
# File 'lib/spinach/runner/scenario.rb', line 33 def steps @steps ||= data['steps'] end |