提交 dd55830b 编写于 作者: M Matthew Mongeau 提交者: wycats

to_sentence should return a duplicate

上级 c017041e
......@@ -26,7 +26,7 @@ def to_sentence(options = {})
when 0
""
when 1
self[0].to_s
self[0].to_s.dup
when 2
"#{self[0]}#{options[:two_words_connector]}#{self[1]}"
else
......
......@@ -82,6 +82,11 @@ def test_one_element
assert_equal "one", ['one'].to_sentence
end
def test_one_element_not_same_object
elements = ["one"]
assert_not_equal elements[0].object_id, elements.to_sentence.object_id
end
def test_one_non_string_element
assert_equal '1', [1].to_sentence
end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册