From 74c5e440e3776c1c69aa644c872b41cb81c9025b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Rasmusson?= Date: Mon, 2 Oct 2017 18:58:49 +0200 Subject: [PATCH] Handle the --retry option in profiles, fixes #1050. --- CHANGELOG.md | 2 +- lib/cucumber/cli/options.rb | 2 ++ spec/cucumber/cli/options_spec.rb | 20 ++++++++++++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) 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