Permalink
Browse files

do not use --profile parallel when user gave a profile, fixes #120

  • Loading branch information...
1 parent d5595f1 commit 8a38f02b65045d72bf50be5fb5c6b179329db061 @grosser committed May 5, 2012
Showing with 31 additions and 9 deletions.
  1. +10 −3 lib/parallel_tests/cucumber/runner.rb
  2. +21 −6 spec/parallel_tests/cucumber/runner_spec.rb
@@ -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)
@@ -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"
@@ -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

0 comments on commit 8a38f02

Please sign in to comment.