Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow Rake task to accept multiple profiles. fixes #905 #907

Merged
merged 7 commits into from
Apr 19, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/cucumber/rake/task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def runner(task_args = nil) #:nodoc:
end

def cucumber_opts_with_profile #:nodoc:
@profile ? [cucumber_opts, '--profile', @profile] : cucumber_opts
Array(cucumber_opts).concat Array(@profile).flat_map {|p| ["--profile", p] }
end

def feature_files #:nodoc:
Expand Down
85 changes: 85 additions & 0 deletions spec/cucumber/rake/task_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
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) { %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 %w[ foo bar ] }
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) { %w[ 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 %w[ foo bar --profile fancy ]
end
end

context "with multiple profiles" do
let(:profile) { %w[ fancy 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

context "without cucumber_opts" do
let(:opts) { nil }

context "without profile" do
let(:profile) { nil }

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 %w[ --profile fancy ]
end
end

context "with multiple profiles" do
let(:profile) { %w[ fancy 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
end
end
end
end