-
Notifications
You must be signed in to change notification settings - Fork 0
/
player_spec.rb
54 lines (35 loc) · 1.01 KB
/
player_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
require_relative 'player'
describe Player do
before do
@initial_health = 150
@player = Player.new("stuboki", @initial_health)
end
it "Has capitalized name" do
expect(@player.name).to eq("Stuboki")
end
it "has an initial health" do
expect(@player.health).to eq(150)
end
it "has a string representation" do
expect(@player.to_s).to eq("I'm Stuboki with a health of 150 and a score of 157.")
end
it "computes a score as the sum of its health and length of name" do
expect(@player.score).to eq(150 + 7)
end
it "increases health by 15 when w00ted" do
@player.w00t
expect(@player.health).to eq(@initial_health + 15)
end
it "decreases health by 10 when blammed" do
@player.blam
expect(@player.health).to eq(@initial_health - 10)
end
context "with a health greater than 100" do
before do
@player = Player.new("quoc", 150)
end
it "is strong" do
expect(@player.strong?).to eq(true)
end
end
end