-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgame_spec.rb
51 lines (25 loc) · 855 Bytes
/
game_spec.rb
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
51
require_relative 'game'
describe Game do
before do
@game = Game.new("Knuckleheads")
@initial_health = 100
@player = Player.new("moe", @initial_health)
@game.add_player(@player)
end
it "w00ts the player if a high number is rolled" do
# or with RSpec 3:
allow_any_instance_of(Die).to receive(:roll).and_return(5)
@game.play(2)
expect(@player.health).to eq(@initial_health + 15 * 2)
end
it "skips the player when a rolled number is medium" do
allow_any_instance_of(Die).to receive(:roll).and_return(3)
@game.play(2)
expect(@player.health).to eq(@initial_health)
end
it "decreases health player when a rolled number is low" do
allow_any_instance_of(Die).to receive(:roll).and_return(1)
@game.play(2)
expect(@player.health).to eq(@initial_health - 10 * 2)
end
end