Skip to content

Commit

Permalink
completed dealing no cards scenario
Browse files Browse the repository at this point in the history
  • Loading branch information
cfeduke committed Oct 24, 2011
1 parent 385ea59 commit 0199498
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
7 changes: 4 additions & 3 deletions features/deal.feature
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,20 @@ Feature: dealer deals cards

As a card dealer
I want to deal a card
@wip

Scenario: deal one card
Given I have a deck of 52 randomly ordered cards
When there are 52 cards remaining
And I deal a card
Then I should be dealt a card
And I should have one less card remaining in the deck

Scenario: deal no cards
Given I have a deck with no cards remaining
When I deal a card
Then I should not be dealt a card


@wip
Scenario: deal all cards
Given I have a deck of 52 randomly ordered cards
When I deal a card 52 times
Expand Down
14 changes: 12 additions & 2 deletions features/step_definitions/deck_of_cards_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
end

Then /^they should have Ace, 2-10, Jack, Queen, King in four suits$/ do
Card::SUITS.each_index do |suit_index|
Card::SUITS.each_index do | suit_index |
suit = Card::SUITS[suit_index]
Card::FACES.each_index do |face_index|
Card::FACES.each_index do | face_index |
card = @deck.cards[(suit_index * 13) + face_index]
card.suit.should == suit
card.face.should == Card::FACES[face_index]
Expand Down Expand Up @@ -54,3 +54,13 @@
Then /^I should have one less card remaining in the deck$/ do
@deck.cards.count.should == 51
end

Given /^I have a deck with no cards remaining$/ do
Given("I create a new deck of cards")
52.times { @deck.deal_one_card }
end

Then /^I should not be dealt a card$/ do
@dealt_card = @deck.deal_one_card
@dealt_card.should == nil
end

0 comments on commit 0199498

Please sign in to comment.