Class: Spinach::Runner
- Inherits:
-
Object
- Object
- Spinach::Runner
- Defined in:
- lib/spinach/runner.rb,
lib/spinach/runner/feature_runner.rb,
lib/spinach/runner/scenario_runner.rb
Overview
Runner gets the parsed data from the feature and performs the actual calls to the feature classes.
Direct Known Subclasses
Defined Under Namespace
Classes: FeatureRunner, ScenarioRunner
Instance Attribute Summary collapse
-
#filenames ⇒ Object
readonly
The feature files to run.
-
#step_definitions_path ⇒ Object
readonly
The default path where the steps are located.
-
#support_path ⇒ Object
readonly
The default path where the support files are located.
Instance Method Summary collapse
-
#default_reporter_options ⇒ Object
Default initialization options for the reporter.
-
#init_reporters ⇒ Object
Inits the reporter with a default one.
-
#initialize(filenames, options = {}) ⇒ Runner
constructor
Initializes the runner with a parsed feature.
-
#orderer ⇒ Object
The orderer for this run.
-
#require_dependencies ⇒ Object
Loads support files and step definitions, ensuring that env.rb is loaded first.
-
#require_frameworks ⇒ Object
Requires the test framework support.
-
#required_files ⇒ Array<String>
Files All support files with env.rb ordered first, followed by the step definitions.
-
#run ⇒ true, false
Runs this runner and outputs the results in a colorful manner.
-
#step_definition_files ⇒ Array<String>
Returns an array of files to be required.
-
#support_files ⇒ Array<String>
Returns an array of support files inside the support_path.
Constructor Details
#initialize(filenames, options = {}) ⇒ Runner
Initializes the runner with a parsed feature
30 31 32 33 34 35 36 37 38 |
# File 'lib/spinach/runner.rb', line 30 def initialize(filenames, = {}) @filenames = filenames @step_definitions_path = .delete(:step_definitions_path) || Spinach.config.step_definitions_path @support_path = .delete(:support_path) || Spinach.config.support_path end |
Instance Attribute Details
#filenames ⇒ Object (readonly)
The feature files to run
8 9 10 |
# File 'lib/spinach/runner.rb', line 8 def filenames @filenames end |
#step_definitions_path ⇒ Object (readonly)
The default path where the steps are located
11 12 13 |
# File 'lib/spinach/runner.rb', line 11 def step_definitions_path @step_definitions_path end |
#support_path ⇒ Object (readonly)
The default path where the support files are located
14 15 16 |
# File 'lib/spinach/runner.rb', line 14 def support_path @support_path end |
Instance Method Details
#default_reporter_options ⇒ Object
Default initialization options for the reporter
143 144 145 |
# File 'lib/spinach/runner.rb', line 143 def {orderer: orderer} end |
#init_reporters ⇒ Object
Inits the reporter with a default one.
43 44 45 46 47 48 49 50 |
# File 'lib/spinach/runner.rb', line 43 def init_reporters Spinach.config[:reporter_classes].each do |reporter_class| = .merge(Spinach.config.) reporter = Support.constantize(reporter_class).new() reporter.bind end end |
#orderer ⇒ Object
The orderer for this run.
135 136 137 138 139 |
# File 'lib/spinach/runner.rb', line 135 def orderer @orderer ||= Support.constantize(Spinach.config[:orderer_class]).new( seed: Spinach.config.seed ) end |
#require_dependencies ⇒ Object
Loads support files and step definitions, ensuring that env.rb is loaded first.
83 84 85 86 87 |
# File 'lib/spinach/runner.rb', line 83 def require_dependencies required_files.each do |file| require file end end |
#require_frameworks ⇒ Object
Requires the test framework support
91 92 93 |
# File 'lib/spinach/runner.rb', line 91 def require_frameworks require_relative 'frameworks' end |
#required_files ⇒ Array<String>
Returns files All support files with env.rb ordered first, followed by the step definitions.
128 129 130 |
# File 'lib/spinach/runner.rb', line 128 def required_files support_files + step_definition_files end |
#run ⇒ true, false
Runs this runner and outputs the results in a colorful manner.
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/spinach/runner.rb', line 58 def run require_dependencies require_frameworks init_reporters suite_passed = true Spinach.hooks.run_before_run features_to_run.each do |feature| feature_passed = FeatureRunner.new(feature, orderer: orderer).run suite_passed &&= feature_passed break if fail_fast? && !feature_passed end Spinach.hooks.run_after_run(suite_passed) suite_passed end |
#step_definition_files ⇒ Array<String>
Returns an array of files to be required. Sorted by the most nested files first, then alphabetically.
100 101 102 103 104 |
# File 'lib/spinach/runner.rb', line 100 def step_definition_files Dir.glob( File. File.join(step_definitions_path, '**', '*.rb') ).sort{|a,b| [b.count(File::SEPARATOR), a] <=> [a.count(File::SEPARATOR), b]} end |
#support_files ⇒ Array<String>
Returns an array of support files inside the support_path. Will put “env.rb” in the beginning
113 114 115 116 117 118 119 120 121 |
# File 'lib/spinach/runner.rb', line 113 def support_files support_files = Dir.glob( File. File.join(support_path, '**', '*.rb') ) environment_file = support_files.find do |f| f.include?(File.join support_path, 'env.rb') end support_files.unshift(environment_file).compact.uniq end |