More work on verifying tournament round generation

This commit is contained in:
Dan Buch
2012-03-10 22:08:22 -05:00
parent e1f1aa6038
commit 5cf5a8035d
2 changed files with 34 additions and 21 deletions

View File

@@ -5,29 +5,42 @@ describe MashTournament do
@valid_attributes = {:requester_id => 1}
end
before(:each) do
@requester = Requester.make
@requester.save!
subject.requester_id = @requester.id
subject.save!
subject.reload
end
it "should create a new instance given valid attributes" do
MashTournament.create!(@valid_attributes)
end
context 'creating rounds' do
it 'should reject invalid numbers of contenders' do
[11, 24, 40].each do |n|
expect do
subject.create_rounds(n)
end.to raise_error
end
end
before(:all) do
Map.destroy_all
8.times do
40.times do
Map.make.save
end
@requester = Requester.make
@requester.save!
end
before(:each) do
subject.requester_id = @requester.id
subject.save!
subject.reload
end
it 'should create 3 rounds for 8 contenders' do
subject.create_rounds
subject.total_rounds.should == 3
[[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
subject.create_rounds(n_contenders)
subject.total_rounds.should == n_rounds
end
end
end
end
end