Skip to content

Instantly share code, notes, and snippets.

@gstark
Created May 21, 2015 12:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gstark/15e1ca6bea829dd40028 to your computer and use it in GitHub Desktop.
Save gstark/15e1ca6bea829dd40028 to your computer and use it in GitHub Desktop.
require 'minitest/autorun'
GREEN_EGGS_AND_HAM = %{
I am Sam
Sam I am
That Sam-I-am
That Sam-I-am!
I do not like that Sam-I-am
I do not like them, Sam-I-am.
I do not like green eggs and ham.
I would not like them here or there.
I would not like them anywhere.
I do not like green eggs and ham.
I do not like them, Sam-I-am
Would you like them in a house?
Would you like them with a mouse?
I do not like them in a house.
I do not like them with a mouse.
I do not like them here or there.
I do not like them anywhere.
I do not like green eggs and ham.
I do not like them, Sam-I-am.
}
WORDS = GREEN_EGGS_AND_HAM.gsub(/[^A-Za-z-]/, " ").split
class GreenEggs < MiniTest::Test
def test_count_of_total_words
assert_equal 116, 0
end
def test_all_unique_words_sorted
assert_equal ["I", "Sam", "Sam-I-am", "That", "Would", "a", "am", "and", "anywhere", "do", "eggs", "green", "ham", "here", "house", "in", "like", "mouse", "not", "or", "that", "them", "there", "with", "would", "you"], []
end
def test_all_unique_words_and_frequency
expected = {"I"=>15, "am"=>2, "Sam"=>2, "That"=>2, "Sam-I-am"=>6, "do"=>11, "not"=>13, "like"=>15, "that"=>1, "them"=>11, "green"=>3, "eggs"=>3, "and"=>3, "ham"=>3, "would"=>2, "here"=>2, "or"=>2, "there"=>2, "anywhere"=>2, "Would"=>2, "you"=>2, "in"=>2, "a"=>4, "house"=>2, "with"=>2, "mouse"=>2}
assert_equal expected, {}
end
def test_count_of_words_less_than_four_letters
assert_equal 59, 0
end
def test_longest_word
assert_equal "Sam-I-am", ""
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment