forked from turingschool/enums-exercises
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtransform_collections_test.rb
82 lines (71 loc) · 2 KB
/
transform_collections_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
gem 'minitest'
require 'minitest/autorun'
require 'minitest/pride'
class TransformCollectionsTest < Minitest::Test
# You get the first test for free... it's already passing.
def test_capitalize
names = ["alice", "bob", "charlie"]
capitalized_names = []
names.each do |name|
capitalized_names << name.capitalize
end
assert_equal ["Alice", "Bob", "Charlie"], capitalized_names
end
# This test is missing a single line of code
def test_doubles
numbers = [1, 2, 3, 4, 5]
doubles = []
numbers.each do |number|
# write code here
end
assert_equal [2, 4, 6, 8, 10], doubles
end
# This test is missing the whole loop
def test_squares
skip
squares = []
numbers = [1, 2, 3, 4, 5]
# write code here
assert_equal [1, 4, 9, 16, 25], squares
end
# From here on out, you're pretty much on your own...
def test_lengths
skip
names = ["alice", "bob", "charlie", "david", "eve"]
# write code here
assert_equal [5, 3, 7, 5, 3], lengths
end
def test_normalize_zip_codes
skip
numbers = [234, 10, 9119, 38881]
# write code here
assert_equal %w(00234 00010 09119 38881), zip_codes
end
def test_reverse
skip
names = ["alice", "bob", "charlie", "david", "eve"]
# write code here
assert_equal ["ecila", "bob", "eilrahc", "divad", "eve"], backwards
end
def test_words_with_no_vowels
skip
words = ["green", "sheep", "travel", "least", "boat"]
# write code here
assert_equal ["grn", "shp", "trvl", "lst", "bt"], without_vowels
end
def test_trim_last_letter
skip
animals = ["dog", "cat", "mouse", "frog", "platypus"]
#write code here
assert_equal ["do", "ca", "mous", "fro", "platypu"], trimmed
end
end
class TransformCollectionsWithMapTest < Minitest::Test
def test_capitalize_with_map
names = ["alice", "bob", "charlie"]
capitalized_names = names.map do |name|
name.capitalize
end
assert_equal ["Alice", "Bob", "Charlie"], capitalized_names
end
end