-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcaffeine_tests.rb
executable file
·49 lines (40 loc) · 1.07 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
require 'minitest/autorun'
require './human'
require './coffee'
class CaffeineTest < MiniTest::Test
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_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
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
def test_humans_like_different_kinds_of_coffee
bob = Human.new "Bob"
cml = Coffee.new "Chai Mocha Latte"
bob.buy cml
2.times { bob.drink! }
assert cml.empty?
assert_in_epsilon bob.alertness, 0.5
end
end