Skip to content

Commit

Permalink
do not use --profile parallel when user gave a profile, fixes #120
Browse files Browse the repository at this point in the history
  • Loading branch information
grosser committed May 5, 2012
1 parent d5595f1 commit 8a38f02
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 9 deletions.
13 changes: 10 additions & 3 deletions lib/parallel_tests/cucumber/runner.rb
Expand Up @@ -10,8 +10,7 @@ def self.run_tests(test_files, process_number, options)
color,
executable,
(runtime_logging if File.directory?(File.dirname(runtime_log))),
options[:test_options],
cucumber_opts,
cucumber_opts(options[:test_options]),
*test_files
].compact.join(" ")
execute_command(cmd, process_number, options)
Expand Down Expand Up @@ -43,7 +42,15 @@ def self.line_is_result?(line)
line =~ /^\d+ (steps|scenarios)/
end

def self.cucumber_opts
def self.cucumber_opts(given)
if given =~ /--profile/ or given =~ /(^|\s)-p /
given
else
[given, profile_from_config].compact.join(" ")
end
end

def self.profile_from_config
config = 'config/cucumber.yml'
if File.exists?(config) && File.read(config) =~ /^parallel:/
"--profile parallel"
Expand Down
27 changes: 21 additions & 6 deletions spec/parallel_tests/cucumber/runner_spec.rb
Expand Up @@ -53,12 +53,27 @@ def call(*args)
call(['xxx'],1,:test_options => '-p default')
end

it "uses parallel profile if config/cucumber.yml contains it" do
file_contents = 'parallel: -f progress'
ParallelTests::Cucumber::Runner.should_receive(:open).with{|x,y| x =~ %r{script/cucumber .* foo bar --profile parallel}}.and_return mocked_process
File.should_receive(:exists?).with('config/cucumber.yml').and_return true
File.should_receive(:read).with('config/cucumber.yml').and_return file_contents
call(['xxx'],1, :test_options => 'foo bar')
context "with parallel profile in config/cucumber.yml" do
before do
file_contents = 'parallel: -f progress'
File.stub(:exists?).with('config/cucumber.yml').and_return true
File.stub(:read).with('config/cucumber.yml').and_return file_contents
end

it "uses parallel profile" do
ParallelTests::Cucumber::Runner.should_receive(:open).with{|x,y| x =~ %r{script/cucumber .* foo bar --profile parallel xxx}}.and_return mocked_process
call(['xxx'],1, :test_options => 'foo bar')
end

it "uses given profile via --profile" do
ParallelTests::Cucumber::Runner.should_receive(:open).with{|x,y| x =~ %r{script/cucumber .* --profile foo xxx$}}.and_return mocked_process
call(['xxx'],1, :test_options => '--profile foo')
end

it "uses given profile via -p" do
ParallelTests::Cucumber::Runner.should_receive(:open).with{|x,y| x =~ %r{script/cucumber .* -p foo xxx$}}.and_return mocked_process
call(['xxx'],1, :test_options => '-p foo')
end
end

it "does not use parallel profile if config/cucumber.yml does not contain it" do
Expand Down

0 comments on commit 8a38f02

Please sign in to comment.