diff --git a/Gemfile.lock b/Gemfile.lock index fc40d83..2375655 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,8 +1,8 @@ PATH remote: . specs: - parallel_cucumber (0.1.21) - cucumber + parallel_cucumber (0.1.22) + cucumber (~> 2) parallel (~> 1.6) GEM diff --git a/lib/parallel_cucumber/grouper.rb b/lib/parallel_cucumber/grouper.rb index 3eeec28..48c8f81 100644 --- a/lib/parallel_cucumber/grouper.rb +++ b/lib/parallel_cucumber/grouper.rb @@ -19,30 +19,10 @@ def scenario_groups(group_size, options) all_runnable_scenarios = distribution_data.map do |feature| next if feature['elements'].nil? feature['elements'].map do |scenario| - if scenario['keyword'] == 'Scenario' - { - line: "#{feature['uri']}:#{scenario['line']}", - weight: 1 - } - elsif scenario['keyword'] == 'Scenario Outline' - if scenario['examples'] - scenario['examples'].map do |example| - examples_count = example['rows'].count - 1 # Do not count the first row with column names - next unless examples_count > 0 - { - line: "#{feature['uri']}:#{example['line']}", - weight: examples_count - } - end - else # Cucumber 1.3 with -x/--expand or Cucumber > 2.0 - { - line: "#{feature['uri']}:#{scenario['line']}", - weight: 1 - } - end - end + "#{feature['uri']}:#{scenario['line']}" if ['Scenario', 'Scenario Outline'].include?(scenario['keyword']) end end.flatten.compact + group_creator(group_size, all_runnable_scenarios) end @@ -89,14 +69,14 @@ def _expand_profiles(options, config) expand_next = false options.split.map do |option| case - when %w(-p --profile).include?(option) - expand_next = true - next - when expand_next - expand_next = false - _expand_profiles(config[option], config) - else - option + when %w(-p --profile).include?(option) + expand_next = true + next + when expand_next + expand_next = false + _expand_profiles(config[option], config) + else + option end end.compact.join(' ') end @@ -104,10 +84,9 @@ def _expand_profiles(options, config) def group_creator(groups_count, tasks) groups = Array.new(groups_count) { [] } - sorted_tasks = tasks.sort { |t1, t2| t2[:weight] <=> t1[:weight] } - sorted_tasks.each do |task| + tasks.each do |task| group = groups.min_by(&:size) - group.push(task[:line], *Array.new(task[:weight] - 1)) + group.push(task) end groups.reject(&:empty?).map(&:compact) end diff --git a/lib/parallel_cucumber/version.rb b/lib/parallel_cucumber/version.rb index d7abda6..eb1e541 100644 --- a/lib/parallel_cucumber/version.rb +++ b/lib/parallel_cucumber/version.rb @@ -1,3 +1,3 @@ module ParallelCucumber - VERSION = '0.1.21'.freeze + VERSION = '0.1.22'.freeze end # ParallelCucumber diff --git a/parallel_cucumber.gemspec b/parallel_cucumber.gemspec index 89fcc2c..22cfa4e 100644 --- a/parallel_cucumber.gemspec +++ b/parallel_cucumber.gemspec @@ -13,7 +13,7 @@ Gem::Specification.new name, ParallelCucumber::VERSION do |spec| spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } spec.require_paths = 'lib' - spec.add_runtime_dependency 'cucumber' + spec.add_runtime_dependency 'cucumber', '~> 2' spec.add_runtime_dependency 'parallel', '~> 1.6' spec.add_development_dependency 'rubocop', '~> 0.36' end