Permalink
Browse files

Adds NoSeedOrderError and SeedLimitExceededError

  • Loading branch information...
1 parent 297ed50 commit 3f42f34760098ac04e38e0871bd85ee6017968b2 @cadwallion cadwallion committed May 22, 2012
Showing with 14 additions and 0 deletions.
  1. +3 −0 lib/bracket_tree/bracket.rb
  2. +11 −0 spec/unit/bracket_tree/bracket_spec.rb
@@ -2,6 +2,9 @@
module BracketTree
class Bracket
+ class NoSeedOrderError < Exception ; end
+ class SeedLimitExceededError < Exception ; end
+
include Enumerable
attr_accessor :root, :seed_order, :insertion_order
@@ -124,5 +124,16 @@
bracket.find { |n| n.position == 5 }.payload.should == { name: 'player3' }
bracket.find { |n| n.position == 7 }.payload.should == { name: 'player2' }
end
+
+ it 'should raise a NoSeedOrderError if seed order is not present in bracket' do
+ bracket.seed_order = nil
+
+ expect { bracket.seed players }.to raise_error(BracketTree::Bracket::NoSeedOrderError)
+ end
+
+ it 'should raise a SeedLimitExceededError if player count exceeds seed count' do
+ players << { name: 'player5' }
+ expect { bracket.seed players }.to raise_error(BracketTree::Bracket::SeedLimitExceededError)
+ end
end
end

0 comments on commit 3f42f34

Please sign in to comment.