Skip to content

Commit

Permalink
added uno deck integrity check
Browse files Browse the repository at this point in the history
  • Loading branch information
johndbritton committed Apr 8, 2011
1 parent 1356213 commit a8a395e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/cardshark/deck.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,9 @@ module Deck
def size
@cards.size
end

def cards
@cards
end
end
end
15 changes: 15 additions & 0 deletions spec/uno_deck_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,19 @@
it 'should contain 108 cards' do
@uno.size.should == 108
end

it 'should contain one zero in each suit' do
zeros = Hash.new
Cardshark::UnoDeck::SUITS.each do |suit|
zeros[suit] = 0
end
@uno.cards.each do |card|
if card.rank == :zero then
zeros[card.suit] += 1
end
end
Cardshark::UnoDeck::SUITS.each do |suit|
zeros[suit].should == 1
end
end
end

0 comments on commit a8a395e

Please sign in to comment.