diff --git a/CHANGELOG.md b/CHANGELOG.md index f8d53e0e9c..f788a6114a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,7 +22,7 @@ Please visit [cucumber/CONTRIBUTING.md](https://github.com/cucumber/cucumber/blo ### Fixed -* N/A +* Handle the `--retry` option in profiles ([#1050](https://github.com/cucumber/cucumber-ruby/issues/1050) [@brasmusson](https://github.com/brasmusson)) ### Improved diff --git a/lib/cucumber/cli/options.rb b/lib/cucumber/cli/options.rb index e1d4491e5d..51c9d1446e 100644 --- a/lib/cucumber/cli/options.rb +++ b/lib/cucumber/cli/options.rb @@ -508,6 +508,8 @@ def reverse_merge(other_options) @options[:formats] = stdout_formats[0..0] + non_stdout_formats end + @options[:retry] = other_options[:retry] if @options[:retry] == 0 + self end diff --git a/spec/cucumber/cli/options_spec.rb b/spec/cucumber/cli/options_spec.rb index a59022f5e7..929e71a3dd 100644 --- a/spec/cucumber/cli/options_spec.rb +++ b/spec/cucumber/cli/options_spec.rb @@ -335,6 +335,26 @@ def after_parsing(args) expect(options[:duration]).to be false end + + context '--retry ATTEMPTS' do + context '--retry option not defined on the command line' do + it 'uses the --retry option from the profile' do + given_cucumber_yml_defined_as('foo' => '--retry 2') + options.parse!(%w[-p foo]) + + expect(options[:retry]).to be 2 + end + end + + context '--retry option defined on the command line' do + it 'ignores the --retry option from the profile' do + given_cucumber_yml_defined_as('foo' => '--retry 2') + options.parse!(%w[--retry 1 -p foo]) + + expect(options[:retry]).to be 1 + end + end + end end context '-P or --no-profile' do