Class: Cucumber::Cli::Main
Class Method Summary collapse
Instance Method Summary collapse
- #configuration ⇒ Object
- #execute!(step_mother) ⇒ Object
- #group_features(arr, buckets) ⇒ Object
-
#initialize(args, out_stream = STDOUT, error_stream = STDERR) ⇒ Main
constructor
A new instance of Main.
- #tag_excess(features) ⇒ Object
Constructor Details
#initialize(args, out_stream = STDOUT, error_stream = STDERR) ⇒ Main
Returns a new instance of Main.
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/cucumber/cli/main.rb', line 25 def initialize(args, out_stream = STDOUT, error_stream = STDERR) @args = args if Cucumber::WINDOWS_MRI @out_stream = out_stream == STDOUT ? Formatter::ColorIO.new(Kernel, STDOUT) : out_stream else @out_stream = out_stream end @error_stream = error_stream @configuration = nil end |
Class Method Details
.execute(args) ⇒ Object
20 21 22 |
# File 'lib/cucumber/cli/main.rb', line 20 def execute(args) new(args).execute!(step_mother) end |
.step_mother ⇒ Object
16 17 18 |
# File 'lib/cucumber/cli/main.rb', line 16 def step_mother @step_mother ||= StepMother.new end |
Instance Method Details
#configuration ⇒ Object
151 152 153 154 155 156 157 |
# File 'lib/cucumber/cli/main.rb', line 151 def configuration return @configuration if @configuration @configuration = Configuration.new(@out_stream, @error_stream) @configuration.parse!(@args) @configuration end |
#execute!(step_mother) ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 |
# File 'lib/cucumber/cli/main.rb', line 56 def execute!(step_mother) trap_interrupt if configuration.drb? begin return DRbClient.run(@args, @error_stream, @out_stream, configuration.drb_port) rescue DRbClientError => e @error_stream.puts "WARNING: #{e.} Running features locally:" end end if configuration.grid? @step_mother_threads = [] group_features(configuration.feature_files, configuration.[:grid_buckets]).each do |feature_bucket| @step_mother_threads << Thread.new do step_mother = StepMother.new # create configurations and options for each one that are different objects # need a way to point to the configuration object that belongs to that particular thread, maybe a hash? step_mother. = configuration. step_mother.log = configuration.log step_mother.load_code_files(configuration.support_to_load) step_mother.after_configuration(configuration) features = step_mother.load_plain_text_features(feature_bucket) features = step_mother.load_plain_text_features(configuration.feature_files) step_mother.load_code_files(feature_bucket) enable_diffing tag_excess = tag_excess(features) # debugger configuration.[:tag_excess] = tag_excess # Hack to make it available in console.rb - later: stick on Run instance. runner = configuration.build_runner(step_mother, @out_stream) step_mother.visitor = runner # Needed to support World#announce runner.visit_features(features) failure = if tag_excess.any? true elsif configuration.wip? step_mother.scenarios(:passed).any? else step_mother.scenarios(:failed).any? || (configuration.strict? && (step_mother.steps(:undefined).any? || step_mother.steps(:pending).any?)) end end.join # debugger # debugger end else step_mother. = configuration. step_mother.log = configuration.log step_mother.load_code_files(configuration.support_to_load) step_mother.after_configuration(configuration) features = step_mother.load_plain_text_features(configuration.feature_files) step_mother.load_code_files(configuration.step_defs_to_load) enable_diffing tag_excess = tag_excess(features) configuration.[:tag_excess] = tag_excess # Hack to make it available in console.rb - later: stick on Run instance. runner = configuration.build_runner(step_mother, @out_stream) step_mother.visitor = runner # Needed to support World#announce runner.visit_features(features) failure = if tag_excess.any? true elsif configuration.wip? step_mother.scenarios(:passed).any? else step_mother.scenarios(:failed).any? || (configuration.strict? && (step_mother.steps(:undefined).any? || step_mother.steps(:pending).any?)) end end rescue ProfilesNotDefinedError, YmlLoadError, ProfileNotFound => e @error_stream.puts e. true end |
#group_features(arr, buckets) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/cucumber/cli/main.rb', line 37 def group_features(arr, buckets) temp = [] buckets = buckets.to_i 1.upto(buckets) do |a| temp << [] end pos = 0 if buckets < arr.size arr.each do |ltr| temp[pos % buckets] << ltr pos += 1 end else temp = arr.map {|a| [a]} end temp end |
#tag_excess(features) ⇒ Object
140 141 142 143 144 145 146 147 148 149 |
# File 'lib/cucumber/cli/main.rb', line 140 def tag_excess(features) configuration.[:tag_expression].limits.map do |tag_name, tag_limit| tag_locations = features.tag_locations(tag_name) if tag_limit && (tag_locations.length > tag_limit) [tag_name, tag_limit, tag_locations] else nil end end.compact end |