Skip to content

Commit 4784fc1

Browse files
author
Brian Dunn
committed
upgrade cucumber
1 parent a93be35 commit 4784fc1

File tree

8 files changed

+38
-33
lines changed

8 files changed

+38
-33
lines changed

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ gemspec name: 'flatware-cucumber'
55

66
group :development do
77
gem 'appraisal'
8-
gem 'aruba', '~> 0.14'
8+
gem 'aruba'
99
gem 'logger'
1010
gem 'ostruct'
1111
gem 'pry'

cucumber.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
default: --publish-quiet

features/step_definitions/flatware_steps.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def duration(&block)
7777
command = ['flatware', args, '-w', max_workers].flatten.compact.join(' ')
7878

7979
@duration = duration do
80-
run_command_and_stop(command, fail_on_exit: false)
80+
run_command(command)
8181
end
8282
end
8383

@@ -113,7 +113,7 @@ def duration(&block)
113113

114114
Then 'the output contains a backtrace' do
115115
trace = <<-TXT.gsub(/^ +/, '')
116-
features/flunk.feature:4:in `Given flunk'
116+
features/flunk.feature:4:in `flunk'
117117
TXT
118118

119119
expect(flatware_process).to have_output Regexp.new Regexp.escape trace

features/support/env.rb

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -14,28 +14,10 @@
1414

1515
World(Module.new do
1616
def max_workers
17-
return 3 if travis?
18-
1917
Etc.nprocessors
2018
end
21-
22-
def travis?
23-
ENV.key? 'TRAVIS'
24-
end
2519
end)
2620

27-
Before do
28-
if travis?
29-
%i[
30-
command
31-
directory
32-
environment
33-
stderr
34-
stdout
35-
].each(&aruba.announcer.method(:activate))
36-
end
37-
end
38-
3921
After do |_scenario|
4022
all_commands.reject(&:stopped?).each do |command|
4123
zombie_pids = Flatware.pids_of_group(command.pid)
@@ -54,10 +36,19 @@ def travis?
5436
end
5537
end
5638

57-
After 'not @non-zero' do |scenario|
58-
expect(flatware_process.exit_status).to eq 0 if flatware_process && (scenario.status == :passed)
59-
end
39+
expect_flatware_exit = lambda do |expected_status|
40+
lambda do |scenario|
41+
return unless scenario.status == :passed && flatware_process
42+
43+
status = begin
44+
last_command_stopped.exit_status
45+
rescue Aruba::NoCommandHasBeenStoppedError
46+
flatware_process.wait.exitstatus
47+
end
6048

61-
After '@non-zero' do |scenario|
62-
expect(flatware_process.exit_status).to eq 1 if flatware_process && (scenario.status == :passed)
49+
expect(status).to eq expected_status
50+
end
6351
end
52+
53+
After('not @non-zero', &expect_flatware_exit.call(0))
54+
After('@non-zero', &expect_flatware_exit.call(1))

flatware-cucumber.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Gem::Specification.new do |s|
2222
s.licenses = ['MIT']
2323
s.required_ruby_version = ['>= 2.6', '< 3.5']
2424
s.require_paths = ['lib']
25-
s.add_dependency %(cucumber), '~> 3.0'
25+
s.add_dependency %(cucumber), '~> 9.1'
2626
s.add_dependency %(flatware), Flatware::VERSION
2727
# s.metadata['rubygems_mfa_required'] = 'true'
2828
end

lib/flatware/cucumber.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,17 @@ def feature_files
3535
def configure(args, out_stream = $stdout, error_stream = $stderr)
3636
raw_args = args.dup
3737
cli_config = ::Cucumber::Cli::Configuration.new(out_stream, error_stream)
38-
cli_config.parse! args + %w[--format Flatware::Cucumber::Formatter]
38+
cli_config.parse! args + %w[--format Flatware::Cucumber::Formatter --publish-quiet]
3939
cucumber_config = ::Cucumber::Configuration.new cli_config
40-
Config.new cucumber_config, raw_args
40+
Config.new(cucumber_config, raw_args)
4141
end
4242

4343
def run(feature_files, options)
4444
runtime(Array(feature_files) + options).run!
4545
end
4646

4747
def runtime(args)
48-
::Cucumber::Runtime.new(configure(args).config)
48+
@runtime ||= ::Cucumber::Runtime.new(configure(args).config)
4949
end
5050
end
5151
end

spec/flatware/cucumber_spec.rb

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,27 @@
3636
FEATURE
3737

3838
Dir.chdir Pathname(Dir.pwd).join('tmp/aruba') do
39-
described_class.run('features/feature_1.feature', [])
40-
described_class.run('features/feature_2.feature', [])
39+
described_class.run([1, 2].map { |n| "features/feature_#{n}.feature" }, [])
4140

4241
expect(Flatware).to have_received(:ran).with(1)
4342
expect(Flatware).to have_received(:ran).with(2)
4443
expect(Flatware).to have_received(:ran).with(3)
4544
expect(Flatware).to have_received(:ran).exactly(3).times
4645
expect(sink).to have_received(:progress).exactly(3).times
47-
expect(sink).to have_received(:checkpoint).exactly(2).times
46+
47+
expect(sink).to have_received(:checkpoint).with(
48+
have_attributes(
49+
scenarios: match_array(
50+
%w[
51+
features/feature_1.feature:2
52+
features/feature_1.feature:4
53+
features/feature_2.feature:2
54+
].map do |file_colon_line|
55+
have_attributes(file_colon_line: file_colon_line)
56+
end
57+
)
58+
)
59+
)
4860
end
4961
end
5062
end

spec/spec_helper.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
RSpec.configure do |config|
1313
config.include WaitingSupport
1414
config.raise_errors_for_deprecations!
15+
config.example_status_persistence_file_path = 'tmp/examples.txt'
1516
config.around :each, :verbose do |example|
1617
Flatware.verbose = true
1718
example.run

0 commit comments

Comments
 (0)