-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeck_spec.rb
More file actions
50 lines (44 loc) · 1.31 KB
/
deck_spec.rb
File metadata and controls
50 lines (44 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
require_relative 'deck'
RSpec.describe Deck do
SUITS = ['Spades', 'Hearts', 'Clubs', 'Diamonds']
RANKS = ['2', '3', '4', '5', '6', '7', '8', '9', '10', 'Jack', 'Queen', 'King', 'Ace']
before do
@deck = Deck.new(SUITS,RANKS)
end
it 'responds to deck' do
expect(@deck).to respond_to(:deck)
end
it 'responds to suits' do
expect(@deck).to respond_to(:suits)
end
it 'responds to ranks' do
expect(@deck).to respond_to(:ranks)
end
it 'responds to shuffle' do
expect(@deck).to respond_to(:shuffle)
end
it 'responds to deal_card' do
expect(@deck).to respond_to(:deal_card)
end
it 'responds to replace_with' do
expect(@deck).to respond_to(:replace_with)
end
it 'pops off the stack when a card is dealt' do
#shuffle deck
#dealt card will be last card that needs to be popped off
#expect deal_card to equal dealt card
dealt_card = @deck.shuffle.last
expect(@deck.deal_card).to eq(dealt_card)
end
it 'dealt card cannot be nil' do
expect(@deck.deal_card).not_to eq(nil)
end
it 'gets a new deck with replace_with' do
deck_of_cards = []
deck_of_cards.push(Card.new('Clubs','2'))
deck_of_cards.push(Card.new('Clubs','3'))
new_deck= @deck.dup
new_deck.replace_with(deck_of_cards)
expect(@deck.deck).not_to eq(new_deck.deck)
end
end