-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcard_spec.rb
More file actions
40 lines (33 loc) · 846 Bytes
/
card_spec.rb
File metadata and controls
40 lines (33 loc) · 846 Bytes
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
require_relative 'card'
RSpec.describe Card do
before do
suit = "Diamonds"
rank = "8"
@card = Card.new(suit, rank)
end
it 'responds to suit' do
expect(@card).to respond_to(:suit)
end
it 'responds to rank' do
expect(@card).to respond_to(:rank)
end
it 'responds to show' do
expect(@card).to respond_to(:show)
end
it "'show' method returns 'true'" do
expect(@card.show).to eq(true)
end
it "'suit' method returns 'Diamonds'" do
expect(@card.suit).to eq('Diamonds')
end
it "'rank' method returns '8'" do
expect(@card.rank).to eq("8")
end
it "outputs rank and suit if 'show' is true" do
expect("#{@card}").to eq("#{@card.rank} of #{@card.suit}")
end
it "does not output anything if 'show' is false" do
@card.show = false
expect("#{@card}").to eq("")
end
end