Class: Spinach::Runner::Feature
- Inherits:
-
Object
- Object
- Spinach::Runner::Feature
- Includes:
- Hooks
- Defined in:
- lib/spinach/runner/feature.rb
Overview
A feature runner handles a particular feature run.
Instance Attribute Summary collapse
-
#filename ⇒ Object
readonly
The file taht describes the feature.
-
#reporter ⇒ Object
readonly
The Spinach::Reporter used in this feature.
Instance Method Summary collapse
-
#data ⇒ Hash
The parsed data for this feature.
-
#feature ⇒ Feature
The feature object used to run this scenario.
-
#feature_name ⇒ String
This feature name.
-
#initialize(filename) ⇒ Feature
constructor
A new instance of Feature.
-
#run ⇒ true, false
Runs this feature.
-
#scenarios ⇒ Hash
The parsed scenarios for this runner’s feature.
Constructor Details
#initialize(filename) ⇒ Feature
Returns a new instance of Feature.
26 27 28 |
# File 'lib/spinach/runner/feature.rb', line 26 def initialize(filename) @filename, @scenario_line = filename.split(':') end |
Instance Attribute Details
#filename ⇒ Object (readonly)
The file taht describes the feature.
14 15 16 |
# File 'lib/spinach/runner/feature.rb', line 14 def filename @filename end |
#reporter ⇒ Object (readonly)
The Spinach::Reporter used in this feature.
11 12 13 |
# File 'lib/spinach/runner/feature.rb', line 11 def reporter @reporter end |
Instance Method Details
#data ⇒ Hash
Returns The parsed data for this feature.
46 47 48 |
# File 'lib/spinach/runner/feature.rb', line 46 def data @data ||= Spinach::Parser.new(filename).parse end |
#feature ⇒ Feature
Returns The feature object used to run this scenario.
38 39 40 |
# File 'lib/spinach/runner/feature.rb', line 38 def feature @feature ||= Spinach.find_feature(feature_name).new end |
#feature_name ⇒ String
Returns This feature name.
54 55 56 |
# File 'lib/spinach/runner/feature.rb', line 54 def feature_name @feature_name ||= data['name'] end |
#run ⇒ true, false
Runs this feature.
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/spinach/runner/feature.rb', line 72 def run run_hook :before_run, data feature.run_hook :before, data scenarios.each do |scenario| if !@scenario_line || scenario['line'].to_s == @scenario_line @success = Scenario.new(feature_name, feature, scenario).run end end feature.run_hook :after, data run_hook :after_run, data rescue Spinach::FeatureStepsNotFoundException => e run_hook :when_not_found, data, e ensure return !!@success end |
#scenarios ⇒ Hash
Returns The parsed scenarios for this runner’s feature.
62 63 64 |
# File 'lib/spinach/runner/feature.rb', line 62 def scenarios @scenarios ||= (data['elements'] || []) end |