aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/core_ext/string_ext_test.rb
diff options
context:
space:
mode:
authorRyan Oblak <rroblak@gmail.com>2011-09-22 12:17:42 -0700
committerJosé Valim <jose.valim@gmail.com>2011-09-23 15:36:33 +0200
commit310565f537b5eeb134e9a4bb0801358432f03e04 (patch)
tree03ffd726f0788a64c2163d1130727b6a2d8a2aa3 /activesupport/test/core_ext/string_ext_test.rb
parentd62fc8e0211ca2657899f061888d1756a3c257dd (diff)
downloadrails-310565f537b5eeb134e9a4bb0801358432f03e04.tar.gz
rails-310565f537b5eeb134e9a4bb0801358432f03e04.tar.bz2
rails-310565f537b5eeb134e9a4bb0801358432f03e04.zip
Added ActiveSupport::Inflector.safe_constantize and String#safe_constantize; refactored common constantize tests into ConstantizeTestCases
Diffstat (limited to 'activesupport/test/core_ext/string_ext_test.rb')
-rw-r--r--activesupport/test/core_ext/string_ext_test.rb23
1 files changed, 22 insertions, 1 deletions
diff --git a/activesupport/test/core_ext/string_ext_test.rb b/activesupport/test/core_ext/string_ext_test.rb
index 81a284dded..5c1dddaf96 100644
--- a/activesupport/test/core_ext/string_ext_test.rb
+++ b/activesupport/test/core_ext/string_ext_test.rb
@@ -2,6 +2,7 @@
require 'date'
require 'abstract_unit'
require 'inflector_test_cases'
+require 'constantize_test_cases'
require 'active_support/inflector'
require 'active_support/core_ext/string'
@@ -9,9 +10,17 @@ require 'active_support/time'
require 'active_support/core_ext/string/strip'
require 'active_support/core_ext/string/output_safety'
+module Ace
+ module Base
+ class Case
+ end
+ end
+end
+
class StringInflectionsTest < Test::Unit::TestCase
include InflectorTestCases
-
+ include ConstantizeTestCases
+
def test_erb_escape
string = [192, 60].pack('CC')
expected = 192.chr + "&lt;"
@@ -292,6 +301,18 @@ class StringInflectionsTest < Test::Unit::TestCase
"\354\225\204\353\246\254\353\236\221 \354\225\204\353\246\254 \354\225\204\353\235\274\353\246\254\354\230\244".force_encoding('UTF-8').truncate(10)
end
end
+
+ def test_constantize
+ run_constantize_tests_on do |string|
+ string.constantize
+ end
+ end
+
+ def test_safe_constantize
+ run_safe_constantize_tests_on do |string|
+ string.safe_constantize
+ end
+ end
end
class StringBehaviourTest < Test::Unit::TestCase