-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhobbit_test.rb
55 lines (47 loc) · 1.23 KB
/
hobbit_test.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
gem 'minitest', '~> 5.2'
require 'minitest/autorun'
require 'minitest/pride'
require_relative 'hobbit'
class HobbitTest < Minitest::Test
def test_it_has_a_name
hobbit = Hobbit.new("Bilbo")
assert_equal "Bilbo", hobbit.name
end
def test_it_is_named_something_else
hobbit = Hobbit.new("Peregrin")
assert_equal "Peregrin", hobbit.name
end
def test_disposition_is_unadventurous
hobbit = Hobbit.new("Samwise")
assert_equal "homebody", hobbit.disposition
end
def test_can_have_a_different_disposition
hobbit = Hobbit.new("Frodo", "adventurous")
assert_equal "adventurous", hobbit.disposition
end
def test_grows_older_when_celebrating_birthdays
hobbit = Hobbit.new('Meriadoc')
assert_equal 0, hobbit.age
5.times do
hobbit.celebrate_birthday
end
assert_equal 5, hobbit.age
end
def test_is_considered_a_child_at_32
hobbit = Hobbit.new('Gerontius')
32.times do
hobbit.celebrate_birthday
end
refute hobbit.adult?
end
def test_comes_of_age_at_33
hobbit = Hobbit.new('Otho')
33.times do
hobbit.celebrate_birthday
end
assert hobbit.adult?
# still adult, one year later
hobbit.celebrate_birthday
assert hobbit.adult?
end
end