Might actually have tournament round filling working correctly (?)

This commit is contained in:
Dan Buch
2012-03-11 23:24:45 -04:00
parent efd2178294
commit 73cff897a3
2 changed files with 35 additions and 20 deletions

View File

@@ -1,14 +1,14 @@
require 'spec_helper'
describe MashTournamentBuilder do
let(:subject) do
let(ENV['MOCK'].nil? ? :subject : :real_subject) do
MashTournamentBuilder.new(
MashTournament.make(:requester => Requester.make),
MashTournament, MashTournamentRound, Map, Mash
)
end
let(:mock_subject) do
let(ENV['MOCK'].nil? ? :mock_subject : :subject) do
@tournament = mock(Object)
@tournament_model = mock(Object)
@round_model = mock(Object)
@@ -21,6 +21,13 @@ describe MashTournamentBuilder do
)
end
before(:all) do
subject.map_model.destroy_all
40.times do
subject.map_model.make.save
end
end
context 'creating rounds' do
it 'should reject invalid numbers of contenders' do
[11, 24, 40].each do |n|
@@ -30,13 +37,6 @@ describe MashTournamentBuilder do
end
end
before(:all) do
subject.map_model.destroy_all
40.times do
subject.map_model.make.save
end
end
[[8, 3], [16, 4], [32, 5]].each do |n_contenders,n_rounds|
context "for #{n_contenders} total contenders" do
it "should create #{n_rounds} rounds" do
@@ -49,13 +49,13 @@ describe MashTournamentBuilder do
context 'filling in rounds' do
before(:each) do
subject.id.should_not be_nil
subject.tournament.id.should_not be_nil
subject.create_rounds_for_contenders(8)
end
xit 'should fill in every map for every mash in a given round' do
it 'should fill in every map for every mash in a given round' do
subject.fill_in_next_round
subject.round(1).mashes.each do |mash|
subject.tournament.round(1).mashes.each do |mash|
mash.map_a.should_not be_nil
mash.map_b.should_not be_nil
end