Skip to content

Instantly share code, notes, and snippets.

@kalarani
Created September 11, 2015 09:07
Show Gist options
  • Save kalarani/76d99ef69288a59d9c89 to your computer and use it in GitHub Desktop.
Save kalarani/76d99ef69288a59d9c89 to your computer and use it in GitHub Desktop.
Intro to TDD
class StringUtil
def reverse a_string
a_string.reverse
end
end
class StringUtil
def reverse a_string
reversed_string = []
a_string.split("").each_with_index do |char, index|
reversed_string[a_string.length - index] = char
end
reversed_string.join
end
end
describe StringUtil do
it 'should reverse a string' do
string_util = StringUtil.new
reversed_string = string_util.reverse('This is a test')
expect(reversed_string).to eq 'tset a si sihT'
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment