diff options
author | oss92 <mohamed.o.alnagdy@gmail.com> | 2016-07-13 13:46:43 +0200 |
---|---|---|
committer | oss92 <mohamed.o.alnagdy@gmail.com> | 2016-07-13 20:19:26 +0200 |
commit | b937c24edc21ba1b2cb0d6e64d2ccddcad2a7a12 (patch) | |
tree | c3d04b80b2317df5155c08749910c2d713a48772 /activesupport/test | |
parent | e1915e712d654838e4a734a6f9f0327494095c8e (diff) | |
download | rails-b937c24edc21ba1b2cb0d6e64d2ccddcad2a7a12.tar.gz rails-b937c24edc21ba1b2cb0d6e64d2ccddcad2a7a12.tar.bz2 rails-b937c24edc21ba1b2cb0d6e64d2ccddcad2a7a12.zip |
Added :fallback_string option to Array#to_sentence
Diffstat (limited to 'activesupport/test')
-rw-r--r-- | activesupport/test/core_ext/array/conversions_test.rb | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/activesupport/test/core_ext/array/conversions_test.rb b/activesupport/test/core_ext/array/conversions_test.rb index de36e2026d..323b451e02 100644 --- a/activesupport/test/core_ext/array/conversions_test.rb +++ b/activesupport/test/core_ext/array/conversions_test.rb @@ -25,6 +25,11 @@ class ToSentenceTest < ActiveSupport::TestCase assert_equal "one, two and three", ['one', 'two', 'three'].to_sentence(last_word_connector: ' and ') end + def test_to_sentence_with_fallback_string + assert_equal "none", [].to_sentence(fallback_string: 'none') + assert_equal "one, two, and three", ['one', 'two', 'three'].to_sentence(fallback_string: 'none') + end + def test_two_elements assert_equal "one and two", ['one', 'two'].to_sentence assert_equal "one two", ['one', 'two'].to_sentence(two_words_connector: ' ') @@ -58,7 +63,7 @@ class ToSentenceTest < ActiveSupport::TestCase ['one', 'two'].to_sentence(passing: 'invalid option') end - assert_equal exception.message, "Unknown key: :passing. Valid keys are: :words_connector, :two_words_connector, :last_word_connector, :locale" + assert_equal exception.message, "Unknown key: :passing. Valid keys are: :words_connector, :two_words_connector, :last_word_connector, :locale, :fallback_string" end def test_always_returns_string |