require 'spec_helper' describe ParallelTests::Cucumber do test_tests_in_groups(ParallelTests::Cucumber::Runner, 'features', ".feature") describe :run_tests do before do ParallelTests.stub!(:bundler_enabled?).and_return false File.stub!(:file?).with('.bundle/environment.rb').and_return false File.stub!(:file?).with('script/cucumber').and_return true end def call(*args) ParallelTests::Cucumber::Runner.run_tests(*args) end it "uses TEST_ENV_NUMBER=blank when called for process 0" do ParallelTests::Cucumber::Runner.should_receive(:open).with{|x,y| x=~/TEST_ENV_NUMBER= /}.and_return mocked_process call(['xxx'],0,{}) end it "uses TEST_ENV_NUMBER=2 when called for process 1" do ParallelTests::Cucumber::Runner.should_receive(:open).with{|x,y| x=~/TEST_ENV_NUMBER=2/}.and_return mocked_process call(['xxx'],1,{}) end it "returns the output" do io = open('spec/spec_helper.rb') $stdout.stub!(:print) ParallelTests::Cucumber::Runner.should_receive(:open).and_return io call(['xxx'],1,{})[:stdout].should =~ /\$LOAD_PATH << File/ end it "runs bundle exec cucumber when on bundler 0.9" do ParallelTests.stub!(:bundler_enabled?).and_return true ParallelTests::Cucumber::Runner.should_receive(:open).with{|x,y| x =~ %r{bundle exec cucumber}}.and_return mocked_process call(['xxx'],1,{}) end it "runs script/cucumber when script/cucumber is found" do ParallelTests::Cucumber::Runner.should_receive(:open).with{|x,y| x =~ %r{script/cucumber}}.and_return mocked_process call(['xxx'],1,{}) end it "runs cucumber by default" do File.stub!(:file?).with('script/cucumber').and_return false ParallelTests::Cucumber::Runner.should_receive(:open).with{|x,y| x !~ %r{(script/cucumber)|(bundle exec cucumber)}}.and_return mocked_process call(['xxx'],1,{}) end it "uses options passed in" do ParallelTests::Cucumber::Runner.should_receive(:open).with{|x,y| x =~ %r{script/cucumber .* -p default}}.and_return mocked_process call(['xxx'],1,:test_options => '-p default') end end describe :find_results do it "finds multiple results in test output" do output = <