Class: Launcuke::Runner
- Inherits:
-
Object
- Object
- Launcuke::Runner
- Defined in:
- lib/launcuke/runner.rb
Overview
Actual clas that will spawn one command process per directory of features collected according to configuration
Instance Attribute Summary collapse
-
#dry_run ⇒ Object
Optional.
-
#excluded_dirs ⇒ Object
Optional regexp for name of features directories to exclude.
-
#extra_options ⇒ Object
Array of extra options to pass to the command.
-
#features_root_path ⇒ Object
Root path to your features directory.
-
#forks_pool_size ⇒ Object
Define the size for the pool of forks.
-
#included_only_dirs ⇒ Object
Optional only the features directories to be included.
-
#launch_time ⇒ Object
Define last launch time, display in index.html.
-
#mode ⇒ Object
Define the launch mode, parallel or sequential.
-
#output_dir_name ⇒ Object
Optional name for directory containing the reports.
-
#output_path ⇒ Object
Optional full path for generated reports.
-
#reports_path ⇒ Object
readonly
Full final path where html reports will be generated.
-
#require_features_root_option ⇒ Object
Add cucumber –require option load *.rb files under features root path by default unless specified to false.
-
#system_command ⇒ Object
Delegate to a wrapper of system call in order mock/test.
Instance Method Summary collapse
-
#initialize(features_root) {|_self| ... } ⇒ Runner
constructor
A new instance of Runner.
- #start ⇒ Object
Constructor Details
#initialize(features_root) {|_self| ... } ⇒ Runner
Returns a new instance of Runner.
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/launcuke/runner.rb', line 102 def initialize(features_root) @features_root_path = features_root yield self if block_given? ||= [] @mode = [2]? "#{@extra_options[2]}" : 'sequential' .delete_at(2) @dry_run = false if dry_run.nil? @forks_pool_size ||= 5 @require_features_root_option = true if require_features_root_option.nil? @output_dir_name = "#{@extra_options[1]}" unless output_dir_name @output_path = File.("../reports", output_dir_name) unless output_path @excluded_dirs ||= [] @included_only_dirs ||= [] @launch_time = Time.now.strftime('%Y-%m-%d %H:%M:%S') @reports_path = File.join(output_path, output_dir_name) @system_command ||= SystemCommand.new end |
Instance Attribute Details
#dry_run ⇒ Object
Optional. If true will generate index file but not launch processes. Used for testing.
88 89 90 |
# File 'lib/launcuke/runner.rb', line 88 def dry_run @dry_run end |
#excluded_dirs ⇒ Object
Optional regexp for name of features directories to exclude.
73 74 75 |
# File 'lib/launcuke/runner.rb', line 73 def excluded_dirs @excluded_dirs end |
#extra_options ⇒ Object
Array of extra options to pass to the command. Ex: [“-p”, “my_profile”, “–backtrace”]
79 80 81 |
# File 'lib/launcuke/runner.rb', line 79 def end |
#features_root_path ⇒ Object
Root path to your features directory. Ex: your_project/features
64 65 66 |
# File 'lib/launcuke/runner.rb', line 64 def features_root_path @features_root_path end |
#forks_pool_size ⇒ Object
Define the size for the pool of forks. Default is 5
82 83 84 |
# File 'lib/launcuke/runner.rb', line 82 def forks_pool_size @forks_pool_size end |
#included_only_dirs ⇒ Object
Optional only the features directories to be included
76 77 78 |
# File 'lib/launcuke/runner.rb', line 76 def included_only_dirs @included_only_dirs end |
#launch_time ⇒ Object
Define last launch time, display in index.html
100 101 102 |
# File 'lib/launcuke/runner.rb', line 100 def launch_time @launch_time end |
#mode ⇒ Object
Define the launch mode, parallel or sequential
97 98 99 |
# File 'lib/launcuke/runner.rb', line 97 def mode @mode end |
#output_dir_name ⇒ Object
Optional name for directory containing the reports. Default to ‘cucumber_reports’
67 68 69 |
# File 'lib/launcuke/runner.rb', line 67 def output_dir_name @output_dir_name end |
#output_path ⇒ Object
Optional full path for generated reports. Default to ../#features_root_path.
70 71 72 |
# File 'lib/launcuke/runner.rb', line 70 def output_path @output_path end |
#reports_path ⇒ Object (readonly)
Full final path where html reports will be generated
85 86 87 |
# File 'lib/launcuke/runner.rb', line 85 def reports_path @reports_path end |
#require_features_root_option ⇒ Object
Add cucumber –require option load *.rb files under features root path by default unless specified to false.
91 92 93 |
# File 'lib/launcuke/runner.rb', line 91 def require_features_root_option @require_features_root_option end |
#system_command ⇒ Object
Delegate to a wrapper of system call in order mock/test
94 95 96 |
# File 'lib/launcuke/runner.rb', line 94 def system_command @system_command end |
Instance Method Details
#start ⇒ Object
120 121 122 123 124 125 126 127 |
# File 'lib/launcuke/runner.rb', line 120 def start FileUtils.mkdir_p reports_path exit_status = launch_process collect_results reports = ReportsIndex.new(reports_path, features_dirs, @launch_time).generate puts "See reports index at #{reports.index_path}" if reports system_command.exit(exit_status) end |