aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/core_ext/array
diff options
context:
space:
mode:
authorAkshay Vishnoi <akshay.vishnoi@vinsol.com>2014-07-29 20:05:36 +0530
committerAkshay Vishnoi <akshay.vishnoi@vinsol.com>2014-07-29 20:05:36 +0530
commit6bc7e27c191b76015b21c22c31da38593bd6f367 (patch)
tree9cad28c4719e9b18ad11ebacb37042ac6d9bbc51 /activesupport/test/core_ext/array
parent8426897086a3ad08cc7280d7af26cb5ccf352922 (diff)
downloadrails-6bc7e27c191b76015b21c22c31da38593bd6f367.tar.gz
rails-6bc7e27c191b76015b21c22c31da38593bd6f367.tar.bz2
rails-6bc7e27c191b76015b21c22c31da38593bd6f367.zip
Add missing test case for Array#to_sentence, collect all test cases for Object#to_param at one place and avoid repitition
Diffstat (limited to 'activesupport/test/core_ext/array')
-rw-r--r--activesupport/test/core_ext/array/conversions_test.rb30
1 files changed, 8 insertions, 22 deletions
diff --git a/activesupport/test/core_ext/array/conversions_test.rb b/activesupport/test/core_ext/array/conversions_test.rb
index 51ad9897da..577b889410 100644
--- a/activesupport/test/core_ext/array/conversions_test.rb
+++ b/activesupport/test/core_ext/array/conversions_test.rb
@@ -52,6 +52,14 @@ class ToSentenceTest < ActiveSupport::TestCase
def test_with_blank_elements
assert_equal ", one, , two, and three", [nil, 'one', '', 'two', 'three'].to_sentence
end
+
+ def test_with_invalid_options
+ exception = assert_raise ArgumentError do
+ ['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"
+ end
end
class ToSTest < ActiveSupport::TestCase
@@ -187,25 +195,3 @@ class ToXmlTest < ActiveSupport::TestCase
assert_equal({ skip_instruct: true }, options)
end
end
-
-class ToParamTest < ActiveSupport::TestCase
- class ToParam < String
- def to_param
- "#{self}1"
- end
- end
-
- def test_string_array
- assert_equal '', %w().to_param
- assert_equal 'hello/world', %w(hello world).to_param
- assert_equal 'hello/10', %w(hello 10).to_param
- end
-
- def test_number_array
- assert_equal '10/20', [10, 20].to_param
- end
-
- def test_to_param_array
- assert_equal 'custom1/param1', [ToParam.new('custom'), ToParam.new('param')].to_param
- end
-end