Class: Spinach::Runner::FeatureRunner
- Inherits:
-
Object
- Object
- Spinach::Runner::FeatureRunner
- Defined in:
- lib/spinach/runner/feature_runner.rb
Overview
A feature runner handles a particular feature run.
Instance Attribute Summary collapse
-
#filename ⇒ Object
readonly
The file taht describes the feature.
Instance Method Summary collapse
-
#data ⇒ Hash
The parsed data for this feature.
-
#feature_name ⇒ String
This feature name.
-
#initialize(filename) ⇒ FeatureRunner
constructor
A new instance of FeatureRunner.
-
#run ⇒ true, false
Runs this feature.
-
#scenarios ⇒ Hash
The parsed scenarios for this runner’s feature.
Constructor Details
#initialize(filename) ⇒ FeatureRunner
Returns a new instance of FeatureRunner.
16 17 18 |
# File 'lib/spinach/runner/feature_runner.rb', line 16 def initialize(filename) @filename, @scenario_line = filename.split(':') end |
Instance Attribute Details
#filename ⇒ Object (readonly)
The file taht describes the feature.
8 9 10 |
# File 'lib/spinach/runner/feature_runner.rb', line 8 def filename @filename end |
Instance Method Details
#data ⇒ Hash
Returns The parsed data for this feature.
28 29 30 |
# File 'lib/spinach/runner/feature_runner.rb', line 28 def data @data ||= Spinach::Parser.open_file(filename).parse end |
#feature_name ⇒ String
Returns This feature name.
36 37 38 |
# File 'lib/spinach/runner/feature_runner.rb', line 36 def feature_name @feature_name ||= data['name'] end |
#run ⇒ true, false
Runs this feature.
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/spinach/runner/feature_runner.rb', line 54 def run Spinach.hooks.run_before_feature data if Spinach.find_feature_steps(feature_name) scenarios.each do |scenario| if !@scenario_line || scenario['line'].to_s == @scenario_line success = ScenarioRunner.new(feature_name, scenario).run @failed = true unless success end end else Spinach.hooks.run_on_undefined_feature data @failed = true end Spinach.hooks.run_after_feature data !@failed end |
#scenarios ⇒ Hash
Returns The parsed scenarios for this runner’s feature.
44 45 46 |
# File 'lib/spinach/runner/feature_runner.rb', line 44 def scenarios @scenarios ||= (data['elements'] || []) end |