Created
July 25, 2012 15:16
-
-
Save zeroeth/3176720 to your computer and use it in GitHub Desktop.
no irb test driven example
This file contains hidden or 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
| require "test/unit" | |
| class String | |
| def palindrome? | |
| stripped = self.gsub(/\W/,'') | |
| stripped == stripped.reverse | |
| end | |
| end | |
| class TestPalindromeChecker < Test::Unit::TestCase | |
| def test_returns_true | |
| assert "race car".palindrome? | |
| end | |
| def test_returns_false | |
| assert !"xrace car".palindrome? | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment