Class: Multicuke::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/multicuke/runner.rb

Overview

Actual clas that will spawn one command process per directory of features collected according to configuration

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(features_root) {|_self| ... } ⇒ Runner

Returns a new instance of Runner.

Yields:

  • (_self)

Yield Parameters:



89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/multicuke/runner.rb', line 89

def initialize(features_root)
  @features_root_path = features_root

  yield self if block_given?

  @dry_run = false if dry_run.nil?
  @require_features_root_option = true if require_features_root_option.nil?
  @output_dir_name = "cucumber_reports" unless output_dir_name
  @output_path = File.expand_path("..", features_root_path) unless output_path
  @excluded_dirs = [] unless excluded_dirs
  @included_only_dirs = [] unless included_only_dirs
  @extra_options = [] unless extra_options
  @reports_path = File.join(output_path, output_dir_name)
  @system_command = SystemCommand.new unless system_command
end

Instance Attribute Details

#dry_runObject

Optional. If true will generate index file but not launch processes. Used for testing.



81
82
83
# File 'lib/multicuke/runner.rb', line 81

def dry_run
  @dry_run
end

#excluded_dirsObject

Optional regexp for name of features directories to exclude.



69
70
71
# File 'lib/multicuke/runner.rb', line 69

def excluded_dirs
  @excluded_dirs
end

#extra_optionsObject

Array of extra options to pass to the command. Ex: [“-p”, “my_profile”, “–backtrace”]



75
76
77
# File 'lib/multicuke/runner.rb', line 75

def extra_options
  @extra_options
end

#features_root_pathObject

Root path to your features directory. Ex: your_project/features



60
61
62
# File 'lib/multicuke/runner.rb', line 60

def features_root_path
  @features_root_path
end

#included_only_dirsObject

Optional only the features directories to be included



72
73
74
# File 'lib/multicuke/runner.rb', line 72

def included_only_dirs
  @included_only_dirs
end

#output_dir_nameObject

Optional name for directory containing the reports. Default to ‘cucumber_reports’



63
64
65
# File 'lib/multicuke/runner.rb', line 63

def output_dir_name
  @output_dir_name
end

#output_pathObject

Optional full path for generated reports. Default to ../#features_root_path.



66
67
68
# File 'lib/multicuke/runner.rb', line 66

def output_path
  @output_path
end

#reports_pathObject (readonly)

Full final path where html reports will be generated



78
79
80
# File 'lib/multicuke/runner.rb', line 78

def reports_path
  @reports_path
end

#require_features_root_optionObject

Add cucumber –require option load *.rb files under features root path by default unless specified to false.



84
85
86
# File 'lib/multicuke/runner.rb', line 84

def require_features_root_option
  @require_features_root_option
end

#system_commandObject

Delegate to a wrapper of system call in order mock/test



87
88
89
# File 'lib/multicuke/runner.rb', line 87

def system_command
  @system_command
end

Instance Method Details

#startObject



105
106
107
108
109
110
111
112
# File 'lib/multicuke/runner.rb', line 105

def start
  FileUtils.mkdir_p reports_path
  exit_status = launch_process_per_dir
  collect_results
  reports = ReportsIndex.new(reports_path, features_dirs).generate
  puts "See reports index at #{reports.index_path}" if reports
  system_command.exit(exit_status)
end