Sha256: 09606224ae70bdcbfb1ca0bf186e36e1797a33b2591d4c8bcc41f167676cde99

Contents?: true

Size: 1.69 KB

Versions: 30

Compression:

Stored size: 1.69 KB

Contents

require File.expand_path(File.join(File.dirname(__FILE__), '../../lib/server/group'))
require 'test/unit'
require 'shoulda'
require 'flexmock/test_unit'

module Testbot::Server

  class GroupTest < Test::Unit::TestCase

    context "self.build" do

      should "create file groups based on the number of instances" do
        groups = Group.build([ 'spec/models/car_spec.rb', 'spec/models/car2_spec.rb',
                             'spec/models/house_spec.rb', 'spec/models/house2_spec.rb' ], [ 1, 1, 1, 1 ], 2, 'spec')

        assert_equal 2, groups.size
        assert_equal [ 'spec/models/house2_spec.rb', 'spec/models/house_spec.rb' ], groups[0]
        assert_equal [ 'spec/models/car2_spec.rb', 'spec/models/car_spec.rb' ], groups[1]
      end

      should "create a small grop when there isn't enough specs to fill a normal one" do
        groups = Group.build(["spec/models/car_spec.rb", "spec/models/car2_spec.rb",   
                             "spec/models/house_spec.rb", "spec/models/house2_spec.rb",
                             "spec/models/house3_spec.rb"], [ 1, 1, 1, 1, 1 ], 3, 'spec')

        assert_equal 3, groups.size
        assert_equal [ "spec/models/car_spec.rb" ], groups[2]
      end

      should "use sizes when building groups" do
        groups = Group.build([ 'spec/models/car_spec.rb', 'spec/models/car2_spec.rb',
                             'spec/models/house_spec.rb', 'spec/models/house2_spec.rb' ], [ 40, 10, 10, 20 ], 2, 'spec')

        assert_equal [ 'spec/models/car_spec.rb' ], groups[0]
        assert ![ 'spec/models/house2_spec.rb', 'spec/models/car2_spec.rb', 'spec/models/house_spec.rb' ].
          find { |file| !groups[1].include?(file) }      
      end

    end

  end

end

Version data entries

30 entries across 30 versions & 2 rubygems

Version Path
testbot-0.7.12 test/server/group_test.rb
testbot-0.7.11 test/server/group_test.rb
testbot-0.7.9 test/server/group_test.rb
testbot_instructure-0.7.9 test/server/group_test.rb
testbot_instructure-0.7.8 test/server/group_test.rb
testbot-0.7.8 test/server/group_test.rb
testbot-0.7.7 test/server/group_test.rb
testbot-0.7.6 test/server/group_test.rb
testbot-0.7.5 test/server/group_test.rb
testbot-0.7.3 test/server/group_test.rb
testbot-0.7.2 test/server/group_test.rb
testbot-0.7.1 test/server/group_test.rb
testbot-0.7.0 test/server/group_test.rb
testbot-0.6.9 test/server/group_test.rb
testbot-0.6.8 test/server/group_test.rb
testbot-0.6.7 test/server/group_test.rb
testbot-0.6.6 test/server/group_test.rb
testbot-0.6.5 test/server/group_test.rb
testbot-0.6.4 test/server/group_test.rb
testbot-0.6.3 test/server/group_test.rb