Created
September 11, 2015 09:07
-
-
Save kalarani/76d99ef69288a59d9c89 to your computer and use it in GitHub Desktop.
Intro to TDD
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
class StringUtil | |
def reverse a_string | |
a_string.reverse | |
end | |
end |
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
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 |
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
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