class Spinach::Runner::FeatureRunner
A feature runner handles a particular feature run.
Attributes
feature[R]
orderer[R]
Public Class Methods
new(feature, orderer: Spinach::Orderers::Default.new)
click to toggle source
@param [GherkinRuby::AST::Feature] feature
The feature to run.
@api public
# File lib/spinach/runner/feature_runner.rb, line 15 def initialize(feature, orderer: Spinach::Orderers::Default.new) @feature = feature @orderer = orderer end
Public Instance Methods
feature_name()
click to toggle source
@return [String]
This feature name.
@api public
# File lib/spinach/runner/feature_runner.rb, line 24 def feature_name feature.name end
run()
click to toggle source
Runs this feature.
@return [true, false]
Whether the run was successful or not.
@api public
# File lib/spinach/runner/feature_runner.rb, line 42 def run Spinach.hooks.run_before_feature(feature) if Spinach.find_step_definitions(feature_name) run_scenarios! else undefined_steps! end Spinach.hooks.run_after_feature(feature) # FIXME The feature & scenario runners should have the same structure. # They should either both return inverted failure or both return # raw success. !@failed end
scenarios()
click to toggle source
@return [Array<GherkinRuby::AST::Scenario>]
The parsed scenarios for this runner's feature.
@api public
# File lib/spinach/runner/feature_runner.rb, line 32 def scenarios feature.scenarios end
Private Instance Methods
run_scenarios!()
click to toggle source
# File lib/spinach/runner/feature_runner.rb, line 69 def run_scenarios! scenarios_to_run.each do |scenario| success = ScenarioRunner.new(scenario).run @failed = true unless success break if Spinach.config.fail_fast && @failed end end
scenarios_to_run()
click to toggle source
# File lib/spinach/runner/feature_runner.rb, line 84 def scenarios_to_run unordered_scenarios = feature.scenarios.select do |scenario| has_a_tag_that_will_be_run = TagsMatcher.match(feature_tags + scenario.tags) on_a_line_that_will_be_run = if feature.run_every_scenario? true else (scenario.lines & feature.lines_to_run).any? end has_a_tag_that_will_be_run && on_a_line_that_will_be_run end orderer.order(unordered_scenarios) end
undefined_steps!()
click to toggle source
# File lib/spinach/runner/feature_runner.rb, line 78 def undefined_steps! Spinach.hooks.run_on_undefined_feature(feature) @failed = true end