aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/core_ext
diff options
context:
space:
mode:
authorYehuda Katz <wycats@gmail.com>2009-07-19 13:21:17 -0700
committerYehuda Katz <wycats@gmail.com>2009-07-19 13:21:17 -0700
commit37658f15bb88e054635a496327a4a82bb50fd5d5 (patch)
tree78f3d350394910270d1eca3537857111e8f14fe8 /activesupport/test/core_ext
parentf2f5cdc8bcd9df3a297ea02b80dbdb21790de732 (diff)
parent17d5cc12b9f8d0d78a081d231e7e0c5ec9df1104 (diff)
downloadrails-37658f15bb88e054635a496327a4a82bb50fd5d5.tar.gz
rails-37658f15bb88e054635a496327a4a82bb50fd5d5.tar.bz2
rails-37658f15bb88e054635a496327a4a82bb50fd5d5.zip
Merge branch 'master' of git@github.com:rails/rails
Diffstat (limited to 'activesupport/test/core_ext')
-rw-r--r--activesupport/test/core_ext/string_ext_test.rb13
1 files changed, 8 insertions, 5 deletions
diff --git a/activesupport/test/core_ext/string_ext_test.rb b/activesupport/test/core_ext/string_ext_test.rb
index f77ad5236e..a23d3f6fef 100644
--- a/activesupport/test/core_ext/string_ext_test.rb
+++ b/activesupport/test/core_ext/string_ext_test.rb
@@ -311,8 +311,8 @@ class TestGetTextString < Test::Unit::TestCase
end
def test_sprintf_lack_argument
- assert_equal("%{num}, test", "%{num}, %{record}" % {:record => "test"})
- assert_equal("%{record}", "%{record}" % {:num => 1})
+ assert_raises(KeyError) { "%{num}, %{record}" % {:record => "test"} }
+ assert_raises(KeyError) { "%{record}" % {:num => 1} }
end
def test_no_placeholder
@@ -336,9 +336,12 @@ class TestGetTextString < Test::Unit::TestCase
assert_equal("foo 1.000000", "%s %f" % ["foo", 1.0])
end
- def test_sprintf_mix
+ def test_sprintf_mix_unformatted_and_formatted_named_placeholders
assert_equal("foo 1.000000", "%{name} %<num>f" % {:name => "foo", :num => 1.0})
- assert_equal("%{name} 1.000000", "%{name} %f" % [1.0])
- assert_equal("%{name} 1.000000", "%{name} %f" % [1.0, 2.0])
+ end
+
+ def test_string_interpolation_raises_an_argument_error_when_mixing_named_and_unnamed_placeholders
+ assert_raises(ArgumentError) { "%{name} %f" % [1.0] }
+ assert_raises(ArgumentError) { "%{name} %f" % [1.0, 2.0] }
end
end