forked from turingschool/enums-exercises
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathare_there_any_test.rb
105 lines (91 loc) · 2.14 KB
/
are_there_any_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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
gem 'minitest'
require 'minitest/autorun'
require 'minitest/pride'
class AreThereAnyTest < Minitest::Test
# You get the first test for free... it's already passing.
def test_has_a_zero
numbers = [2, 9, 3, 1, 0]
has_zero = false
numbers.each do |number|
has_zero = true if number.zero?
end
assert has_zero
end
# This test is missing a single line of code
def test_has_zeros
skip
numbers = [3, 1, 0, 7, 9, 0]
has_zero = false
numbers.each do |number|
# write code here
end
assert has_zero
end
# This test is missing the whole loop
def test_does_not_have_zero
skip
numbers = [3, 1, 3, 2, 4, 9, 8]
has_zero = false
# write code here
refute has_zero
end
# From here on out, you're pretty much on your own...
def test_no_alice
skip
names = ["chuck", "charlene", "cory", "chris", "carl"]
# write code here
refute has_alice
end
def test_has_alice
skip
names = ["bill", "bob", "burton", "alice", "brandon"]
# write code here
assert has_alice
end
def test_contains_a_multi_word_phrase
skip
names = ['Sure!', 'OK.', 'I have no idea.', 'Really?' 'Whatever.']
# write code here
assert has_multi_word_phrase
end
def test_no_monkeys
skip
animals = ["elephants", "hippos", "jaguars", "pythons"]
# write code here
refute has_monkeys
end
def test_has_multiples_of_5
skip
numbers = [3, 5, 2, 4, 10, 8]
# write code here
assert has_multiple_of_5
end
def test_no_multiples_of_5
skip
numbers = [3, 1, 3, 2, 4, 9, 8]
# write code here
refute has_multiple_of_5
end
def test_no_instances_of_Time
skip
numbers = [3, 1, 3, 2, 4, 9, 8]
# write code here
refute has_no_instances_of_Time
end
def test_has_instance_of_Time
skip
time = Time.now
numbers = [time, 1, 3, 2, 4, 9, 8]
# write code here
refute has_no_instances_of_Time
end
end
class AreThereAnyUsingAnyTest < Minitest::Test
def test_has_a_zero_using_any
numbers = [2, 9, 3, 1, 0]
has_zero = numbers.any? do |number|
number.zero?
end
assert has_zero
end
end