diff --git a/.rubocop.yml b/.rubocop.yml index eff9a44..0af1032 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -9,7 +9,7 @@ # # See https://github.com/rubocop-hq/rubocop/blob/master/manual/configuration.md # -require: +plugins: - rubocop-rake # - rubocop-rspec diff --git a/Gemfile b/Gemfile index aec2f52..2824f9d 100644 --- a/Gemfile +++ b/Gemfile @@ -5,7 +5,7 @@ gemspec name: 'flatware-cucumber' group :development do gem 'appraisal' - gem 'aruba', '~> 0.14' + gem 'aruba' gem 'logger' gem 'ostruct' gem 'pry' diff --git a/cucumber.yml b/cucumber.yml new file mode 100644 index 0000000..ccc974f --- /dev/null +++ b/cucumber.yml @@ -0,0 +1 @@ +default: --publish-quiet \ No newline at end of file diff --git a/features/step_definitions/flatware_steps.rb b/features/step_definitions/flatware_steps.rb index 69711f1..030ae0a 100644 --- a/features/step_definitions/flatware_steps.rb +++ b/features/step_definitions/flatware_steps.rb @@ -77,7 +77,7 @@ def duration(&block) command = ['flatware', args, '-w', max_workers].flatten.compact.join(' ') @duration = duration do - run_command_and_stop(command, fail_on_exit: false) + run_command(command) end end @@ -113,7 +113,7 @@ def duration(&block) Then 'the output contains a backtrace' do trace = <<-TXT.gsub(/^ +/, '') - features/flunk.feature:4:in `Given flunk' + features/flunk.feature:4:in `flunk' TXT expect(flatware_process).to have_output Regexp.new Regexp.escape trace diff --git a/features/support/env.rb b/features/support/env.rb index dd2a12b..5146d7c 100644 --- a/features/support/env.rb +++ b/features/support/env.rb @@ -14,28 +14,10 @@ World(Module.new do def max_workers - return 3 if travis? - Etc.nprocessors end - - def travis? - ENV.key? 'TRAVIS' - end end) -Before do - if travis? - %i[ - command - directory - environment - stderr - stdout - ].each(&aruba.announcer.method(:activate)) - end -end - After do |_scenario| all_commands.reject(&:stopped?).each do |command| zombie_pids = Flatware.pids_of_group(command.pid) @@ -54,10 +36,19 @@ def travis? end end -After 'not @non-zero' do |scenario| - expect(flatware_process.exit_status).to eq 0 if flatware_process && (scenario.status == :passed) -end +expect_flatware_exit = lambda do |expected_status| + lambda do |scenario| + return unless scenario.status == :passed && flatware_process + + status = begin + last_command_stopped.exit_status + rescue Aruba::NoCommandHasBeenStoppedError + flatware_process.wait.exitstatus + end -After '@non-zero' do |scenario| - expect(flatware_process.exit_status).to eq 1 if flatware_process && (scenario.status == :passed) + expect(status).to eq expected_status + end end + +After('not @non-zero', &expect_flatware_exit.call(0)) +After('@non-zero', &expect_flatware_exit.call(1)) diff --git a/flatware-cucumber.gemspec b/flatware-cucumber.gemspec index 47b6694..772f27e 100644 --- a/flatware-cucumber.gemspec +++ b/flatware-cucumber.gemspec @@ -22,7 +22,7 @@ Gem::Specification.new do |s| s.licenses = ['MIT'] s.required_ruby_version = ['>= 2.6', '< 3.5'] s.require_paths = ['lib'] - s.add_dependency %(cucumber), '~> 3.0' + s.add_dependency %(cucumber), '~> 9.1' s.add_dependency %(flatware), Flatware::VERSION # s.metadata['rubygems_mfa_required'] = 'true' end diff --git a/gemfiles/rspec_3.10.gemfile b/gemfiles/rspec_3.10.gemfile index 0b27a9e..186cb79 100644 --- a/gemfiles/rspec_3.10.gemfile +++ b/gemfiles/rspec_3.10.gemfile @@ -6,7 +6,7 @@ gem "rspec", "3.10.0" group :development do gem "appraisal" - gem "aruba", "~> 0.14" + gem "aruba" gem "pry" gem "racc" gem "rake" diff --git a/gemfiles/rspec_3.11.gemfile b/gemfiles/rspec_3.11.gemfile index 05e24b2..9f3c0e0 100644 --- a/gemfiles/rspec_3.11.gemfile +++ b/gemfiles/rspec_3.11.gemfile @@ -6,7 +6,7 @@ gem "rspec", "3.11.0" group :development do gem "appraisal" - gem "aruba", "~> 0.14" + gem "aruba" gem "pry" gem "racc" gem "rake" diff --git a/gemfiles/rspec_3.12.gemfile b/gemfiles/rspec_3.12.gemfile index 6264d6f..ed81aea 100644 --- a/gemfiles/rspec_3.12.gemfile +++ b/gemfiles/rspec_3.12.gemfile @@ -6,7 +6,7 @@ gem "rspec", "3.12.0" group :development do gem "appraisal" - gem "aruba", "~> 0.14" + gem "aruba" gem "pry" gem "racc" gem "rake" diff --git a/gemfiles/rspec_3.13.gemfile b/gemfiles/rspec_3.13.gemfile index 9a4a683..e8648d4 100644 --- a/gemfiles/rspec_3.13.gemfile +++ b/gemfiles/rspec_3.13.gemfile @@ -6,7 +6,7 @@ gem "rspec", "3.13.0" group :development do gem "appraisal" - gem "aruba", "~> 0.14" + gem "aruba" gem "pry" gem "racc" gem "rake" diff --git a/gemfiles/rspec_3.6.gemfile b/gemfiles/rspec_3.6.gemfile index 7283dd8..ea2e2bf 100644 --- a/gemfiles/rspec_3.6.gemfile +++ b/gemfiles/rspec_3.6.gemfile @@ -6,7 +6,7 @@ gem "rspec", "3.6.0" group :development do gem "appraisal" - gem "aruba", "~> 0.14" + gem "aruba" gem "pry" gem "racc" gem "rake" diff --git a/gemfiles/rspec_3.7.gemfile b/gemfiles/rspec_3.7.gemfile index 9fcc482..411db5e 100644 --- a/gemfiles/rspec_3.7.gemfile +++ b/gemfiles/rspec_3.7.gemfile @@ -6,7 +6,7 @@ gem "rspec", "3.7.0" group :development do gem "appraisal" - gem "aruba", "~> 0.14" + gem "aruba" gem "pry" gem "racc" gem "rake" diff --git a/gemfiles/rspec_3.8.gemfile b/gemfiles/rspec_3.8.gemfile index a55a9bf..c9f5f97 100644 --- a/gemfiles/rspec_3.8.gemfile +++ b/gemfiles/rspec_3.8.gemfile @@ -6,7 +6,7 @@ gem "rspec", "3.8.0" group :development do gem "appraisal" - gem "aruba", "~> 0.14" + gem "aruba" gem "pry" gem "racc" gem "rake" diff --git a/gemfiles/rspec_3.9.gemfile b/gemfiles/rspec_3.9.gemfile index 559951b..d60226a 100644 --- a/gemfiles/rspec_3.9.gemfile +++ b/gemfiles/rspec_3.9.gemfile @@ -6,7 +6,7 @@ gem "rspec", "3.9.0" group :development do gem "appraisal" - gem "aruba", "~> 0.14" + gem "aruba" gem "pry" gem "racc" gem "rake" diff --git a/lib/flatware/cucumber.rb b/lib/flatware/cucumber.rb index e821905..f5b3f43 100644 --- a/lib/flatware/cucumber.rb +++ b/lib/flatware/cucumber.rb @@ -35,9 +35,9 @@ def feature_files def configure(args, out_stream = $stdout, error_stream = $stderr) raw_args = args.dup cli_config = ::Cucumber::Cli::Configuration.new(out_stream, error_stream) - cli_config.parse! args + %w[--format Flatware::Cucumber::Formatter] + cli_config.parse! args + %w[--format Flatware::Cucumber::Formatter --publish-quiet] cucumber_config = ::Cucumber::Configuration.new cli_config - Config.new cucumber_config, raw_args + Config.new(cucumber_config, raw_args) end def run(feature_files, options) @@ -45,7 +45,7 @@ def run(feature_files, options) end def runtime(args) - ::Cucumber::Runtime.new(configure(args).config) + @runtime ||= ::Cucumber::Runtime.new(configure(args).config) end end end diff --git a/spec/flatware/cucumber_spec.rb b/spec/flatware/cucumber_spec.rb index 9fbcb11..147a004 100644 --- a/spec/flatware/cucumber_spec.rb +++ b/spec/flatware/cucumber_spec.rb @@ -36,15 +36,27 @@ FEATURE Dir.chdir Pathname(Dir.pwd).join('tmp/aruba') do - described_class.run('features/feature_1.feature', []) - described_class.run('features/feature_2.feature', []) + described_class.run([1, 2].map { |n| "features/feature_#{n}.feature" }, []) expect(Flatware).to have_received(:ran).with(1) expect(Flatware).to have_received(:ran).with(2) expect(Flatware).to have_received(:ran).with(3) expect(Flatware).to have_received(:ran).exactly(3).times expect(sink).to have_received(:progress).exactly(3).times - expect(sink).to have_received(:checkpoint).exactly(2).times + + expect(sink).to have_received(:checkpoint).with( + have_attributes( + scenarios: match_array( + %w[ + features/feature_1.feature:2 + features/feature_1.feature:4 + features/feature_2.feature:2 + ].map do |file_colon_line| + have_attributes(file_colon_line: file_colon_line) + end + ) + ) + ) end end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 47b1915..5dd22d6 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -12,6 +12,7 @@ RSpec.configure do |config| config.include WaitingSupport config.raise_errors_for_deprecations! + config.example_status_persistence_file_path = 'tmp/examples.txt' config.around :each, :verbose do |example| Flatware.verbose = true example.run