Created
November 17, 2015 09:20
-
-
Save vinayvinay/68fbae3eaa9344ad07e8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# zoomer_sentence_reversor.rb | |
def sentence_reversor(str=nil) | |
return "ERROR: Pass-in a string to reverse as an argument" if str.nil? | |
str.split.reverse.join(" ") | |
end | |
# puts sentence_reversor(ARGV[0]) | |
# zoomer_sentence_reversor_test.rb | |
require 'test/unit' | |
require './zoomer_sentence_reversor' | |
class ZoomerSentenceReversorTest < Test::Unit::TestCase | |
def test_single_word_remains_unchanged | |
assert(sentence_reversor('one') == 'one') | |
end | |
def test_sentence_gets_reversed | |
assert(sentence_reversor('the big black cat') == 'cat black big the') | |
end | |
def test_error_message_when_no_input_provided | |
assert(sentence_reversor() == 'ERROR: Pass-in a string to reverse as an argument') | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment