forked from AdaGold/clock
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclock_test.rb
More file actions
67 lines (51 loc) · 1.29 KB
/
clock_test.rb
File metadata and controls
67 lines (51 loc) · 1.29 KB
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
59
60
61
62
63
64
65
66
67
# clock_test.rb
# clock_test.rb
require 'minitest/autorun'
require 'minitest/reporters'
require_relative '../lib/clock'
Minitest::Reporters.use!
describe "clock" do
it "can be called with hours, minutes and seconds as arguments" do
# Arrange
hours = 11
minutes = 14
seconds = 27
# Act
time = clock(hours, minutes, seconds)
# Assert
# the `clock` method must return a string
expect(time).must_be_instance_of String
end
it "will return a string formatted in hh:mm:ss format" do
# Arrange
hours = 11
minutes = 14
seconds = 27
# Act
time = clock(hours, minutes, seconds)
# Assert
expect((time)).must_equal "11:14:27"
end
it "will display leading zeros for numbers smaller than 10" do
time = clock(11, 8, 14)
expect(time).must_equal "11:08:14"
time = clock(8, 11, 14);
expect(time).must_equal "08:11:14"
time = clock(11, 14, 8);
expect(time).must_equal "11:14:08"
end
it "will raise an error when given an invalid argument" do
expect {
clock(25, 14, 8)
}.must_raise ArgumentError
expect {
clock(11, 60, 8)
}.must_raise ArgumentError
expect {
clock(11, 14, 60)
}.must_raise ArgumentError
expect {
clock(11, 14, -1)
}.must_raise ArgumentError
end
end