-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbob_test.rb
141 lines (108 loc) · 3.6 KB
/
bob_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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
require 'minitest/autorun'
require 'minitest/pride'
begin
require_relative 'bob'
rescue LoadError => e
eval("\"#{DATA.read}\n\"").split("\n.\n").each_with_index do |s,i|
if i > 0
puts "\t--- press enter to continue ---"
gets
end
puts "\n\n", s, "\n\n\n"
end
exit!
end
class TeenagerTest < MiniTest::Unit::TestCase
attr_reader :teenager
def setup
@teenager = ::Bob.new
end
def test_stating_something
assert_equal 'Whatever.', teenager.hey('Tom-ay-to, tom-aaaah-to.')
end
def test_shouting
assert_equal 'Woah, chill out!', teenager.hey('WATCH OUT!')
end
def test_asking_a_question
assert_equal 'Sure.', teenager.hey('Does this cryogenic chamber make me look fat?')
end
def test_asking_a_numeric_question
assert_equal 'Sure.', teenager.hey('You are, what, like 15?')
end
def test_talking_forcefully
assert_equal 'Whatever.', teenager.hey("Let's go make out behind the gym!")
end
def test_using_acronyms_in_regular_speech
assert_equal 'Whatever.', teenager.hey("It's OK if you don't want to go to the DMV.")
end
def test_forceful_questions
assert_equal 'Woah, chill out!', teenager.hey('WHAT THE HELL WERE YOU THINKING?')
end
def test_shouting_numbers
assert_equal 'Woah, chill out!', teenager.hey('1, 2, 3 GO!')
end
def test_only_numbers
assert_equal 'Whatever.', teenager.hey('1, 2, 3')
end
def test_question_with_only_numbers
assert_equal 'Sure.', teenager.hey('4?')
end
def test_shouting_with_special_characters
assert_equal 'Woah, chill out!', teenager.hey('ZOMG THE %^*@#$(*^ ZOMBIES ARE COMING!!11!!1!')
end
def test_shouting_with_no_exclamation_mark
assert_equal 'Woah, chill out!', teenager.hey('I HATE YOU')
end
def test_statement_containing_question_mark
assert_equal 'Whatever.', teenager.hey('Ending with ? means a question.')
end
def test_prattling_on
assert_equal 'Sure.', teenager.hey("Wait! Hang on. Are you going to be OK?")
end
def test_silence
assert_equal 'Fine. Be that way!', teenager.hey('')
end
def test_prolonged_silence
assert_equal 'Fine. Be that way!', teenager.hey(' ')
end
def test_on_multiple_line_questions
assert_equal 'Whatever.', teenager.hey(%{
Does this cryogenic chamber make me look fat?
no})
end
end
__END__
######## ######## ######## ####### ########
## ## ## ## ## ## ## ## ##
## ## ## ## ## ## ## ## ##
###### ######## ######## ## ## ########
## ## ## ## ## ## ## ## ##
## ## ## ## ## ## ## ## ##
######## ## ## ## ## ####### ## ##
#{e.backtrace.first} #{e.message}
Welcome to your first ruby Exercism exercise! This is your first error message.
.
First it tells you the name of the file where the error is occurring:
bob_test.rb
.
Then it tells you which line that error is on:
bob_test.rb:4
.
After that, it tells you the name of the method where the error is occurring:
in `require_relative'
.
Next, it tells you exactly what the error is:
#{e.message.split('--').first}
.
Finally, it tells you which file is missing:
#{e.message.split('--').last}
.
So the error is there on line 4 of this file (bob_test.rb). What's on line 4?
require_relative 'bob'
We are trying to require the file, and it isn't there.
.
You can fix the problem by creating an empty file named bob.rb inside
of the ruby/bob directory.
Then run this test again (ruby bob_test.rb). Make all the tests pass,
and submit your solution (exercism submit bob.rb).
More instructions are in README.md in this directory. Good luck!