Skip to content

Instantly share code, notes, and snippets.

@dgmstuart
Created October 13, 2013 17:05
Show Gist options
  • Save dgmstuart/6964604 to your computer and use it in GitHub Desktop.
Save dgmstuart/6964604 to your computer and use it in GitHub Desktop.
require 'minitest/autorun'
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_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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment