diff options
author | Xavier Noria <fxn@hashref.com> | 2011-10-29 18:03:35 -0700 |
---|---|---|
committer | Xavier Noria <fxn@hashref.com> | 2011-10-29 18:10:45 -0700 |
commit | 11f6795b238172c4a13176062bd38b83285799b7 (patch) | |
tree | a70a883974bf91bbecb4ca11d26409243eaf9a30 /activesupport/test/core_ext/string_ext_test.rb | |
parent | 8ef1bd9b293678b3d9c07a3f63384781df78b6ad (diff) | |
download | rails-11f6795b238172c4a13176062bd38b83285799b7.tar.gz rails-11f6795b238172c4a13176062bd38b83285799b7.tar.bz2 rails-11f6795b238172c4a13176062bd38b83285799b7.zip |
defines Module#qualified_const_(defined?|get|set) and String#deconstantize
This commit also implements a faster version of #demodulize I was unable
to isolate with git add --patch.
Not a big fan of the name #deconstantize. It complements #demodulize
getting rid of the rightmost constant, hence the name, but it is
unrelated to the well-known #constantize. So unsure. Could not come
with anything better, please feel free to rename.
Diffstat (limited to 'activesupport/test/core_ext/string_ext_test.rb')
-rw-r--r-- | activesupport/test/core_ext/string_ext_test.rb | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/activesupport/test/core_ext/string_ext_test.rb b/activesupport/test/core_ext/string_ext_test.rb index 4d876954cf..ade09efc56 100644 --- a/activesupport/test/core_ext/string_ext_test.rb +++ b/activesupport/test/core_ext/string_ext_test.rb @@ -111,6 +111,10 @@ class StringInflectionsTest < Test::Unit::TestCase assert_equal "Account", "MyApplication::Billing::Account".demodulize end + def test_deconstantize + assert_equal "MyApplication::Billing", "MyApplication::Billing::Account".deconstantize + end + def test_foreign_key ClassNameToForeignKeyWithUnderscore.each do |klass, foreign_key| assert_equal(foreign_key, klass.foreign_key) |