test/test_rrschedule.rb in rrschedule-0.1.4 vs test/test_rrschedule.rb in rrschedule-0.1.5
- old
+ new
@@ -13,20 +13,20 @@
assert schedule.shuffle_initial_order
assert schedule.wdays.select{|w| (0..6).member? w} == schedule.wdays
assert schedule.exclude_dates.empty?
end
- should "have a dummy team when team number is odd" do
+ should "have a dummy team when number of teams is odd" do
schedule = RRSchedule::Schedule.new(
:teams => Array(1..9)
)
assert schedule.teams.size == 10
assert schedule.teams.member?(:dummy), "There should always be a :dummy team when the nbr of teams is odd"
end
- should "not have a dummy team when team number is even" do
+ should "not have a dummy team when number of teams is even" do
schedule = RRSchedule::Schedule.new(
:teams => Array(1..6)
)
assert schedule.teams.size == 6
@@ -67,11 +67,11 @@
assert_equal [DateTime.parse("10:00 AM")], schedule.game_times
assert_equal ["the only one"], schedule.playing_surfaces
end
- should "have at least one team specified" do
+ should "have at least two teams" do
assert_raise RuntimeError do
schedule = RRSchedule::Schedule.new(:teams => [1])
end
end
@@ -79,10 +79,29 @@
schedule = RRSchedule::Schedule.new
assert schedule.teams.size > 1
end
end
+ context "Any valid schedule" do
+ setup do
+ @s = RRSchedule::Schedule.new(
+ :teams => %w(a b c d e f g h i j l m),
+ :playing_surfaces => %w(one two),
+ :game_times => ["10:00 AM", "13:00 PM"]
+ )
+ end
+
+ should "have gamedays that respect the wdays attribute" do
+ @s.wdays = [3,5]
+ @s.generate
+
+ @s.gamedays.each do |gd|
+ assert [3,5].include?(gd.date.wday), "wday is #{gd.date.wday.to_s} but should be 3 or 5"
+ end
+ end
+ end
+
context "A generated schedule with an odd number of teams" do
setup do
@s = RRSchedule::Schedule.new(
:teams => %w(a b c d e f g h i j l),
:playing_surfaces => %w(one two),
@@ -92,12 +111,12 @@
should "be a valid round-robin" do
assert @s.round_robin?
end
- should "not have any :dummy teams in the schedule" do
- assert @s.gamedays.collect{|gd,games| games}.flatten.select{
+ should "not have any :dummy teams in the final schedule" do
+ assert @s.gamedays.collect{|gd| gd.games}.flatten.select{
|g| [g.team_a,g.team_b].include?(:dummy)
}.size == 0
end
end
@@ -112,12 +131,12 @@
should "be a valid round-robin" do
assert @s.round_robin?
end
- should "not have any :dummy teams in the schedule" do
- assert @s.gamedays.collect{|gd,games| games}.flatten.select{
+ should "not have any :dummy teams in the final schedule" do
+ assert @s.gamedays.collect{|gd| gd.games}.flatten.select{
|g| [g.team_a,g.team_b].include?(:dummy)
}.size == 0
- end
- end
+ end
+ end
end