require File.dirname(__FILE__) + '/spec_helper' describe ParallelTests do test_tests_in_groups(ParallelTests, 'test', '_test.rb') describe :parse_rake_args do it "should return the count" do args = {:count => 2} ParallelTests.parse_rake_args(args).should == [2, '', ""] end it "should default to the prefix" do args = {:count => "models"} ParallelTests.parse_rake_args(args).should == [2, "models", ""] end it "should return the count and prefix" do args = {:count => 2, :path_prefix => "models"} ParallelTests.parse_rake_args(args).should == [2, "models", ""] end it "should return the count, prefix, and options" do args = {:count => 2, :path_prefix => "plain", :options => "-p default" } ParallelTests.parse_rake_args(args).should == [2, "plain", "-p default"] end end describe :run_tests do it "uses TEST_ENV_NUMBER=blank when called for process 0" do ParallelTests.should_receive(:open).with{|x,y|x=~/TEST_ENV_NUMBER= /}.and_return mock(:getc=>false) ParallelTests.run_tests(['xxx'],0,'') end it "uses TEST_ENV_NUMBER=2 when called for process 1" do ParallelTests.should_receive(:open).with{|x,y| x=~/TEST_ENV_NUMBER=2/}.and_return mock(:getc=>false) ParallelTests.run_tests(['xxx'],1,'') end it "uses options" do ParallelTests.should_receive(:open).with{|x,y| x=~ %r{ruby -Itest -v}}.and_return mock(:getc=>false) ParallelTests.run_tests(['xxx'],1,'-v') end it "returns the output" do io = open('spec/spec_helper.rb') ParallelTests.stub!(:print) ParallelTests.should_receive(:open).and_return io ParallelTests.run_tests(['xxx'],1,'').should =~ /\$LOAD_PATH << File/ end end describe :find_results do it "finds multiple results in test output" do output = <