Trying to get round generation and fill figured out TDD style

This commit is contained in:
Dan Buch
2012-03-10 21:13:03 -05:00
parent f177ecde2a
commit e1f1aa6038
6 changed files with 55 additions and 26 deletions

View File

@@ -3,9 +3,13 @@ require 'sham'
require 'faker'
Sham.location do
"#{Faker::Address.city}, #{Faker::Address.uk_country}"
end
Map.blueprint do
name { Sham.location }
end
@@ -25,5 +29,11 @@ end
Requester.blueprint do
ip do
parts = []
4.times do
parts << (rand * 100).to_i.to_s
end
parts.join('.')
end
end

View File

@@ -2,12 +2,32 @@ require 'spec_helper'
describe MashTournament do
before(:each) do
@valid_attributes = {
:requester_id => 1
}
@valid_attributes = {:requester_id => 1}
end
it "should create a new instance given valid attributes" do
MashTournament.create!(@valid_attributes)
end
context 'creating rounds' do
before(:all) do
Map.destroy_all
8.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
end
end
end