From 3ab3e5815834686c0f456b2fd50e21946173b17e Mon Sep 17 00:00:00 2001 From: Jason Karns Date: Fri, 14 Aug 2015 21:45:04 -0400 Subject: [PATCH 1/7] beginning rake-task specs --- spec/cucumber/rake/task_spec.rb | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 spec/cucumber/rake/task_spec.rb diff --git a/spec/cucumber/rake/task_spec.rb b/spec/cucumber/rake/task_spec.rb new file mode 100644 index 0000000000..bae8e9ddae --- /dev/null +++ b/spec/cucumber/rake/task_spec.rb @@ -0,0 +1,25 @@ +require 'spec_helper' +require 'cucumber/rake/task' +require 'rake' + +module Cucumber + module Rake + describe Task do + + describe "#cucumber_opts" do + before { subject.cucumber_opts = opts } + + context "when set via array" do + let(:opts) { [ :foo, :bar ] } + it { expect(subject.cucumber_opts).to be opts } + end + + context "when set via space-delimited string" do + let(:opts) { "foo bar" } + it { expect(subject.cucumber_opts).to eq [ "foo", "bar" ] } + end + end + + end + end +end From eab9bf3c35f87365f4ad977785eca29906922106 Mon Sep 17 00:00:00 2001 From: Jason Karns Date: Fri, 14 Aug 2015 22:00:04 -0400 Subject: [PATCH 2/7] specs around current cucumber_opts_with_profile behavior --- spec/cucumber/rake/task_spec.rb | 46 +++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/spec/cucumber/rake/task_spec.rb b/spec/cucumber/rake/task_spec.rb index bae8e9ddae..faaac73063 100644 --- a/spec/cucumber/rake/task_spec.rb +++ b/spec/cucumber/rake/task_spec.rb @@ -20,6 +20,52 @@ module Rake end end + describe "#cucumber_opts_with_profile" do + before do + subject.cucumber_opts = opts + subject.profile = profile + end + + context "with cucumber_opts" do + let(:opts) { [ :foo, :bar ] } + + context "without profile" do + let(:profile) { nil } + + it "should return just cucumber_opts" do + expect(subject.cucumber_opts_with_profile).to be opts + end + end + + context "with profile" do + let(:profile) { "fancy" } + + it "should combine opts and profile into an array, prepending --profile option" do + expect(subject.cucumber_opts_with_profile).to eq [ [:foo, :bar], "--profile", "fancy" ] + end + end + end + + context "without cucumber_opts" do + let(:opts) { nil } + + context "without profile" do + let(:profile) { nil } + + it "should return just cucumber_opts" do + expect(subject.cucumber_opts_with_profile).to be opts + end + end + + context "with profile" do + let(:profile) { "fancy" } + + it "should combine opts and profile into an array, prepending --profile option" do + expect(subject.cucumber_opts_with_profile).to eq [ nil, "--profile", "fancy" ] + end + end + end + end end end end From e364e382e018561d8b249f6ac0e6228ae1467b8c Mon Sep 17 00:00:00 2001 From: Jason Karns Date: Fri, 14 Aug 2015 22:05:52 -0400 Subject: [PATCH 3/7] use strings for dummy data --- spec/cucumber/rake/task_spec.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/cucumber/rake/task_spec.rb b/spec/cucumber/rake/task_spec.rb index faaac73063..248c0e5ce8 100644 --- a/spec/cucumber/rake/task_spec.rb +++ b/spec/cucumber/rake/task_spec.rb @@ -10,13 +10,13 @@ module Rake before { subject.cucumber_opts = opts } context "when set via array" do - let(:opts) { [ :foo, :bar ] } + let(:opts) { %w[ foo bar ] } it { expect(subject.cucumber_opts).to be opts } end context "when set via space-delimited string" do let(:opts) { "foo bar" } - it { expect(subject.cucumber_opts).to eq [ "foo", "bar" ] } + it { expect(subject.cucumber_opts).to eq %w[ foo bar ] } end end @@ -27,7 +27,7 @@ module Rake end context "with cucumber_opts" do - let(:opts) { [ :foo, :bar ] } + let(:opts) { %w[ foo bar ] } context "without profile" do let(:profile) { nil } @@ -41,7 +41,7 @@ module Rake let(:profile) { "fancy" } it "should combine opts and profile into an array, prepending --profile option" do - expect(subject.cucumber_opts_with_profile).to eq [ [:foo, :bar], "--profile", "fancy" ] + expect(subject.cucumber_opts_with_profile).to eq [ %w[ foo bar ], "--profile", "fancy" ] end end end From fdd6a14bb535693bebaac83ae1da2c2444b508eb Mon Sep 17 00:00:00 2001 From: Jason Karns Date: Fri, 14 Aug 2015 22:08:19 -0400 Subject: [PATCH 4/7] failing test for new profile behavior --- spec/cucumber/rake/task_spec.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/spec/cucumber/rake/task_spec.rb b/spec/cucumber/rake/task_spec.rb index 248c0e5ce8..df1e98cd9a 100644 --- a/spec/cucumber/rake/task_spec.rb +++ b/spec/cucumber/rake/task_spec.rb @@ -44,6 +44,14 @@ module Rake expect(subject.cucumber_opts_with_profile).to eq [ %w[ foo bar ], "--profile", "fancy" ] end end + + context "with multiple profiles" do + let(:profile) { %w[ fancy pants ] } + + it "should combine opts and profile into an array, prepending --profile option" do + expect(subject.cucumber_opts_with_profile).to eq [ %w[ foo bar ], "--profile", "fancy", "--profile", "pants" ] + end + end end context "without cucumber_opts" do @@ -64,6 +72,14 @@ module Rake expect(subject.cucumber_opts_with_profile).to eq [ nil, "--profile", "fancy" ] end end + + context "with multiple profiles" do + let(:profile) { %w[ fancy pants ] } + + it "should combine opts and profile into an array, prepending --profile option" do + expect(subject.cucumber_opts_with_profile).to eq [ nil, "--profile", "fancy", "--profile", "pants" ] + end + end end end end From b7b86fb79a5a228326252e8db65c1f8a6a36de4d Mon Sep 17 00:00:00 2001 From: Jason Karns Date: Fri, 14 Aug 2015 22:10:18 -0400 Subject: [PATCH 5/7] initial implementation naively add the profile(s) with the --profile option prepended to each one, still returning potentially nested array --- lib/cucumber/rake/task.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/cucumber/rake/task.rb b/lib/cucumber/rake/task.rb index ffccae1157..1690a7ffb9 100644 --- a/lib/cucumber/rake/task.rb +++ b/lib/cucumber/rake/task.rb @@ -153,7 +153,7 @@ def runner(task_args = nil) #:nodoc: end def cucumber_opts_with_profile #:nodoc: - @profile ? [cucumber_opts, '--profile', @profile] : cucumber_opts + @profile ? [cucumber_opts, Array(@profile).flat_map {|p| ["--profile", p] }] : cucumber_opts end def feature_files #:nodoc: From a65ac0822f1656f76a641ad54564e4a45f91d524 Mon Sep 17 00:00:00 2001 From: Jason Karns Date: Fri, 14 Aug 2015 22:12:59 -0400 Subject: [PATCH 6/7] update specs to expect flattened/compacted array --- spec/cucumber/rake/task_spec.rb | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/spec/cucumber/rake/task_spec.rb b/spec/cucumber/rake/task_spec.rb index df1e98cd9a..c53bc87893 100644 --- a/spec/cucumber/rake/task_spec.rb +++ b/spec/cucumber/rake/task_spec.rb @@ -41,15 +41,15 @@ module Rake let(:profile) { "fancy" } it "should combine opts and profile into an array, prepending --profile option" do - expect(subject.cucumber_opts_with_profile).to eq [ %w[ foo bar ], "--profile", "fancy" ] + expect(subject.cucumber_opts_with_profile).to eq %w[ foo bar --profile fancy ] end end context "with multiple profiles" do let(:profile) { %w[ fancy pants ] } - it "should combine opts and profile into an array, prepending --profile option" do - expect(subject.cucumber_opts_with_profile).to eq [ %w[ foo bar ], "--profile", "fancy", "--profile", "pants" ] + it "should combine opts and each profile into an array, prepending --profile option" do + expect(subject.cucumber_opts_with_profile).to eq %w[ foo bar --profile fancy --profile pants ] end end end @@ -60,24 +60,22 @@ module Rake context "without profile" do let(:profile) { nil } - it "should return just cucumber_opts" do - expect(subject.cucumber_opts_with_profile).to be opts - end + it { expect(subject.cucumber_opts_with_profile).to eq [] } end context "with profile" do let(:profile) { "fancy" } it "should combine opts and profile into an array, prepending --profile option" do - expect(subject.cucumber_opts_with_profile).to eq [ nil, "--profile", "fancy" ] + expect(subject.cucumber_opts_with_profile).to eq %w[ --profile fancy ] end end context "with multiple profiles" do let(:profile) { %w[ fancy pants ] } - it "should combine opts and profile into an array, prepending --profile option" do - expect(subject.cucumber_opts_with_profile).to eq [ nil, "--profile", "fancy", "--profile", "pants" ] + it "should combine opts and each profile into an array, prepending --profile option" do + expect(subject.cucumber_opts_with_profile).to eq %w[ --profile fancy --profile pants ] end end end From 80a55db5e52875621b53f209b6bdba347d032a52 Mon Sep 17 00:00:00 2001 From: Jason Karns Date: Fri, 14 Aug 2015 22:18:55 -0400 Subject: [PATCH 7/7] ensure flattened/compacted array --- lib/cucumber/rake/task.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/cucumber/rake/task.rb b/lib/cucumber/rake/task.rb index 1690a7ffb9..6e76fb4761 100644 --- a/lib/cucumber/rake/task.rb +++ b/lib/cucumber/rake/task.rb @@ -153,7 +153,7 @@ def runner(task_args = nil) #:nodoc: end def cucumber_opts_with_profile #:nodoc: - @profile ? [cucumber_opts, Array(@profile).flat_map {|p| ["--profile", p] }] : cucumber_opts + Array(cucumber_opts).concat Array(@profile).flat_map {|p| ["--profile", p] } end def feature_files #:nodoc: