Sha256: 29389f5ccb4fec25b7d9684e37f9693acf01b5090c7a528f593d1e7dce5625c2

Contents?: true

Size: 1.84 KB

Versions: 6

Compression:

Stored size: 1.84 KB

Contents

require "spec_helper"

describe ParallelTests do
  describe ".determine_number_of_processes" do
    before do
      ENV.delete('PARALLEL_TEST_PROCESSORS')
      Parallel.stub(:processor_count).and_return 20
    end

    def call(count)
      ParallelTests.determine_number_of_processes(count)
    end

    it "uses the given count if set" do
      call('5').should == 5
    end

    it "uses the processor count from Parallel" do
      call(nil).should == 20
    end

    it "uses the processor count from ENV before Parallel" do
      ENV['PARALLEL_TEST_PROCESSORS'] = '22'
      call(nil).should == 22
    end

    it "does not use blank count" do
      call('   ').should == 20
    end

    it "does not use blank env" do
      ENV['PARALLEL_TEST_PROCESSORS'] = '   '
      call(nil).should == 20
    end
  end

  describe :bundler_enabled? do
    before do
      Object.stub!(:const_defined?).with(:Bundler).and_return false
    end

    it "should return false" do
      use_temporary_directory_for do
        ParallelTests.send(:bundler_enabled?).should == false
      end
    end

    it "should return true when there is a constant called Bundler" do
      use_temporary_directory_for do
        Object.stub!(:const_defined?).with(:Bundler).and_return true
        ParallelTests.send(:bundler_enabled?).should == true
      end
    end

    it "should be true when there is a Gemfile" do
      use_temporary_directory_for do
        FileUtils.touch("Gemfile")
        ParallelTests.send(:bundler_enabled?).should == true
      end
    end

    it "should be true when there is a Gemfile in the parent directory" do
      use_temporary_directory_for do
        FileUtils.touch(File.join("..", "Gemfile"))
        ParallelTests.send(:bundler_enabled?).should == true
      end
    end
  end

  it "has a version" do
    ParallelTests::VERSION.should =~ /^\d+\.\d+\.\d+/
  end
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
friendlyfashion-parallel_tests-0.9.0 spec/parallel_tests_spec.rb
parallel_tests-0.9.2 spec/parallel_tests_spec.rb
parallel_tests-0.9.1 spec/parallel_tests_spec.rb
parallel_tests-0.9.0 spec/parallel_tests_spec.rb
parallel_tests-0.8.14 spec/parallel_tests_spec.rb
parallel_tests-0.8.13 spec/parallel_tests_spec.rb