Last active
January 4, 2016 07:09
-
-
Save danott/8587012 to your computer and use it in GitHub Desktop.
Make these tests pass and the computer will do serial commas for you!
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 "minitest/autorun" | |
class TestSerialComma < MiniTest::Unit::TestCase | |
def possessives | |
%w[hers his yours mine ours] | |
end | |
def test_possessives_1 | |
assert_equal "hers", serial_comma(places.slice(0, 1)) | |
end | |
def test_possessives_2 | |
skip | |
assert_equal "hers and his", serial_comma(possessives.slice(0, 2)) | |
end | |
def test_possessives_3 | |
skip | |
assert_equal "hers, his, and yours", serial_comma(possessives.slice(0, 3)) | |
end | |
def test_possessives_4 | |
skip | |
assert_equal "hers, his, yours, and mine", serial_comma(possessives.slice(0, 4)) | |
end | |
def test_possessives_5 | |
skip | |
assert_equal "hers, his, yours, mine, and ours", serial_comma(possessives) | |
end | |
def places | |
%w[Seattle Lexington Athens Newcastle] | |
end | |
def test_places_1 | |
skip | |
assert_equal "Seattle", serial_comma(places.slice(0, 1)) | |
end | |
def test_places_2 | |
skip | |
assert_equal "Seattle and Lexington", serial_comma(places.slice(0, 2)) | |
end | |
def test_places_3 | |
skip | |
assert_equal "Seattle, Lexington, and Athens", serial_comma(places.slice(0, 3)) | |
end | |
def test_places_4 | |
skip | |
assert_equal "Seattle, Lexington, Athens, and Newcastle", serial_comma(places) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Fun times. I forked your gist and wrote a method to pass it. If you get a chance let me know what you would do differently.
PS. I updated your test slightly in my first revision. Let me know if I did that incorrectly.