-
Notifications
You must be signed in to change notification settings - Fork 7
/
caffeine_tests.rb
58 lines (46 loc) · 1.25 KB
/
caffeine_tests.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
52
53
54
55
56
57
58
require 'minitest/autorun'
require './human'
require './coffee'
require 'pry'
class CaffeineTest < MiniTest::Test
def test_humans_know_their_name
person = Human.new "Rodney"
assert_equal person.name, "Rodney"
assert_equal person.loud_name, "RODNEY!"
person.name = "Tall Person"
assert_equal person.name, "Tall Person"
end
def test_humans_tend_to_be_sleepy
dave = Human.new "Dave"
assert dave.alertness < 0.1
end
def test_humans_need_coffee
matt = Human.new "Matt"
refute matt.has_coffee?
assert matt.needs_coffee?
end
def test_humans_can_get_coffee
katie = Human.new "Katie"
refute katie.has_coffee?
katie.buy Coffee.new("Latte")
assert katie.has_coffee?
end
def test_humans_can_drink_coffee
mallory = Human.new "Mallory"
tsmf = Coffee.new "Triple Shot Mocha Frappuccino"
assert tsmf.full?
mallory.buy tsmf
mallory.drink!
assert_in_epsilon mallory.alertness, 0.33, 0.1
refute tsmf.full?
refute tsmf.empty?
end
def test_humans_can_drink_all_the_coffee
mallory = Human.new "Mallory"
tsmf = Coffee.new "Triple Shot Mocha Frappuccino"
mallory.buy tsmf
3.times { mallory.drink! }
assert tsmf.empty?
assert mallory.alertness > 0.9
end
end