Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion exercises/bob/.meta/.version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1
2
5 changes: 3 additions & 2 deletions exercises/bob/.meta/generator/bob_case.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

class BobCase < Generator::ExerciseCase
def workload
indent_lines(["remark = #{input.inspect}",
"assert_equal '#{expected}', Bob.hey(remark), %q{Bob hears #{input.inspect}, and..}"
indent_lines(["remark = #{input["heyBob"].inspect}",
"assert_equal #{expected.inspect}, Bob.hey(remark), %q{Bob hears #{input["heyBob"].inspect}, and..}"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯 for using inspect to automatically handle the quoting correctly on the expected value.

], 4)
end
end

4 changes: 3 additions & 1 deletion exercises/bob/.meta/solutions/bob.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module BookKeeping
VERSION = 1
VERSION = 2
end

module Bob
Expand All @@ -11,6 +11,8 @@ def answer(phrase)
case
when phrase.silent?
'Fine. Be that way!'
when phrase.loud? && phrase.quizzical?
'Calm down, I know what I\'m doing!'
when phrase.loud?
'Whoa, chill out!'
when phrase.quizzical?
Expand Down
2 changes: 2 additions & 0 deletions exercises/bob/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ Bob answers 'Sure.' if you ask him a question.

He answers 'Whoa, chill out!' if you yell at him.

He answers 'Calm down, I know what I'm doing!' if you yell a question at him.

He says 'Fine. Be that way!' if you address him without actually saying
anything.

Expand Down
54 changes: 27 additions & 27 deletions exercises/bob/bob_test.rb
Original file line number Diff line number Diff line change
@@ -1,156 +1,156 @@
require 'minitest/autorun'
require_relative 'bob'

# Common test data version: 1.0.0 65756b1
# Common test data version: 1.2.0 6dc2014
class BobTest < Minitest::Test
def test_stating_something
# skip
remark = "Tom-ay-to, tom-aaaah-to."
assert_equal 'Whatever.', Bob.hey(remark), %q{Bob hears "Tom-ay-to, tom-aaaah-to.", and..}
assert_equal "Whatever.", Bob.hey(remark), %q{Bob hears "Tom-ay-to, tom-aaaah-to.", and..}
end

def test_shouting
skip
remark = "WATCH OUT!"
assert_equal 'Whoa, chill out!', Bob.hey(remark), %q{Bob hears "WATCH OUT!", and..}
assert_equal "Whoa, chill out!", Bob.hey(remark), %q{Bob hears "WATCH OUT!", and..}
end

def test_shouting_gibberish
skip
remark = "FCECDFCAAB"
assert_equal 'Whoa, chill out!', Bob.hey(remark), %q{Bob hears "FCECDFCAAB", and..}
assert_equal "Whoa, chill out!", Bob.hey(remark), %q{Bob hears "FCECDFCAAB", and..}
end

def test_asking_a_question
skip
remark = "Does this cryogenic chamber make me look fat?"
assert_equal 'Sure.', Bob.hey(remark), %q{Bob hears "Does this cryogenic chamber make me look fat?", and..}
assert_equal "Sure.", Bob.hey(remark), %q{Bob hears "Does this cryogenic chamber make me look fat?", and..}
end

def test_asking_a_numeric_question
skip
remark = "You are, what, like 15?"
assert_equal 'Sure.', Bob.hey(remark), %q{Bob hears "You are, what, like 15?", and..}
assert_equal "Sure.", Bob.hey(remark), %q{Bob hears "You are, what, like 15?", and..}
end

def test_asking_gibberish
skip
remark = "fffbbcbeab?"
assert_equal 'Sure.', Bob.hey(remark), %q{Bob hears "fffbbcbeab?", and..}
assert_equal "Sure.", Bob.hey(remark), %q{Bob hears "fffbbcbeab?", and..}
end

def test_talking_forcefully
skip
remark = "Let's go make out behind the gym!"
assert_equal 'Whatever.', Bob.hey(remark), %q{Bob hears "Let's go make out behind the gym!", and..}
assert_equal "Whatever.", Bob.hey(remark), %q{Bob hears "Let's go make out behind the gym!", and..}
end

def test_using_acronyms_in_regular_speech
skip
remark = "It's OK if you don't want to go to the DMV."
assert_equal 'Whatever.', Bob.hey(remark), %q{Bob hears "It's OK if you don't want to go to the DMV.", and..}
assert_equal "Whatever.", Bob.hey(remark), %q{Bob hears "It's OK if you don't want to go to the DMV.", and..}
end

def test_forceful_question
skip
remark = "WHAT THE HELL WERE YOU THINKING?"
assert_equal 'Whoa, chill out!', Bob.hey(remark), %q{Bob hears "WHAT THE HELL WERE YOU THINKING?", and..}
assert_equal "Calm down, I know what I'm doing!", Bob.hey(remark), %q{Bob hears "WHAT THE HELL WERE YOU THINKING?", and..}
end

def test_shouting_numbers
skip
remark = "1, 2, 3 GO!"
assert_equal 'Whoa, chill out!', Bob.hey(remark), %q{Bob hears "1, 2, 3 GO!", and..}
assert_equal "Whoa, chill out!", Bob.hey(remark), %q{Bob hears "1, 2, 3 GO!", and..}
end

def test_only_numbers
skip
remark = "1, 2, 3"
assert_equal 'Whatever.', Bob.hey(remark), %q{Bob hears "1, 2, 3", and..}
assert_equal "Whatever.", Bob.hey(remark), %q{Bob hears "1, 2, 3", and..}
end

def test_question_with_only_numbers
skip
remark = "4?"
assert_equal 'Sure.', Bob.hey(remark), %q{Bob hears "4?", and..}
assert_equal "Sure.", Bob.hey(remark), %q{Bob hears "4?", and..}
end

def test_shouting_with_special_characters
skip
remark = "ZOMG THE %^*@\#$(*^ ZOMBIES ARE COMING!!11!!1!"
assert_equal 'Whoa, chill out!', Bob.hey(remark), %q{Bob hears "ZOMG THE %^*@\#$(*^ ZOMBIES ARE COMING!!11!!1!", and..}
assert_equal "Whoa, chill out!", Bob.hey(remark), %q{Bob hears "ZOMG THE %^*@\#$(*^ ZOMBIES ARE COMING!!11!!1!", and..}
end

def test_shouting_with_no_exclamation_mark
skip
remark = "I HATE YOU"
assert_equal 'Whoa, chill out!', Bob.hey(remark), %q{Bob hears "I HATE YOU", and..}
assert_equal "Whoa, chill out!", Bob.hey(remark), %q{Bob hears "I HATE YOU", and..}
end

def test_statement_containing_question_mark
skip
remark = "Ending with ? means a question."
assert_equal 'Whatever.', Bob.hey(remark), %q{Bob hears "Ending with ? means a question.", and..}
assert_equal "Whatever.", Bob.hey(remark), %q{Bob hears "Ending with ? means a question.", and..}
end

def test_non_letters_with_question
skip
remark = ":) ?"
assert_equal 'Sure.', Bob.hey(remark), %q{Bob hears ":) ?", and..}
assert_equal "Sure.", Bob.hey(remark), %q{Bob hears ":) ?", and..}
end

def test_prattling_on
skip
remark = "Wait! Hang on. Are you going to be OK?"
assert_equal 'Sure.', Bob.hey(remark), %q{Bob hears "Wait! Hang on. Are you going to be OK?", and..}
assert_equal "Sure.", Bob.hey(remark), %q{Bob hears "Wait! Hang on. Are you going to be OK?", and..}
end

def test_silence
skip
remark = ""
assert_equal 'Fine. Be that way!', Bob.hey(remark), %q{Bob hears "", and..}
assert_equal "Fine. Be that way!", Bob.hey(remark), %q{Bob hears "", and..}
end

def test_prolonged_silence
skip
remark = " "
assert_equal 'Fine. Be that way!', Bob.hey(remark), %q{Bob hears " ", and..}
assert_equal "Fine. Be that way!", Bob.hey(remark), %q{Bob hears " ", and..}
end

def test_alternate_silence
skip
remark = "\t\t\t\t\t\t\t\t\t\t"
assert_equal 'Fine. Be that way!', Bob.hey(remark), %q{Bob hears "\t\t\t\t\t\t\t\t\t\t", and..}
assert_equal "Fine. Be that way!", Bob.hey(remark), %q{Bob hears "\t\t\t\t\t\t\t\t\t\t", and..}
end

def test_multiple_line_question
skip
remark = "\nDoes this cryogenic chamber make me look fat?\nno"
assert_equal 'Whatever.', Bob.hey(remark), %q{Bob hears "\nDoes this cryogenic chamber make me look fat?\nno", and..}
assert_equal "Whatever.", Bob.hey(remark), %q{Bob hears "\nDoes this cryogenic chamber make me look fat?\nno", and..}
end

def test_starting_with_whitespace
skip
remark = " hmmmmmmm..."
assert_equal 'Whatever.', Bob.hey(remark), %q{Bob hears " hmmmmmmm...", and..}
assert_equal "Whatever.", Bob.hey(remark), %q{Bob hears " hmmmmmmm...", and..}
end

def test_ending_with_whitespace
skip
remark = "Okay if like my spacebar quite a bit? "
assert_equal 'Sure.', Bob.hey(remark), %q{Bob hears "Okay if like my spacebar quite a bit? ", and..}
assert_equal "Sure.", Bob.hey(remark), %q{Bob hears "Okay if like my spacebar quite a bit? ", and..}
end

def test_other_whitespace
skip
remark = "\n\r \t"
assert_equal 'Fine. Be that way!', Bob.hey(remark), %q{Bob hears "\n\r \t", and..}
assert_equal "Fine. Be that way!", Bob.hey(remark), %q{Bob hears "\n\r \t", and..}
end

def test_non_question_ending_with_whitespace
skip
remark = "This is a statement ending with whitespace "
assert_equal 'Whatever.', Bob.hey(remark), %q{Bob hears "This is a statement ending with whitespace ", and..}
assert_equal "Whatever.", Bob.hey(remark), %q{Bob hears "This is a statement ending with whitespace ", and..}
end

# Problems in exercism evolve over time, as we find better ways to ask
Expand All @@ -172,6 +172,6 @@ def test_non_question_ending_with_whitespace

def test_bookkeeping
skip
assert_equal 1, BookKeeping::VERSION
assert_equal 2, BookKeeping::VERSION
end
end