diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2005-02-15 00:51:02 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2005-02-15 00:51:02 +0000 |
commit | c844755e5a0c3d4edfcc78f9c30ef91fa0de550a (patch) | |
tree | 4cf4890fc5af5f58dd0a6a19c0a6fea6ed39a1df /activesupport/test/loading_module_tests.rb | |
parent | a3298e5efdf33398b49933323ea3fef7ff4e9a9c (diff) | |
download | rails-c844755e5a0c3d4edfcc78f9c30ef91fa0de550a.tar.gz rails-c844755e5a0c3d4edfcc78f9c30ef91fa0de550a.tar.bz2 rails-c844755e5a0c3d4edfcc78f9c30ef91fa0de550a.zip |
Merged back the Routing branch
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@614 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport/test/loading_module_tests.rb')
-rw-r--r-- | activesupport/test/loading_module_tests.rb | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/activesupport/test/loading_module_tests.rb b/activesupport/test/loading_module_tests.rb new file mode 100644 index 0000000000..c1d8c7de62 --- /dev/null +++ b/activesupport/test/loading_module_tests.rb @@ -0,0 +1,63 @@ +require 'test/unit' +require '../lib/core_ext.rb' +require '../lib/dependencies.rb' + +STAGING_DIRECTORY = 'loading_module' + +class LoadingModuleTests < Test::Unit::TestCase + def setup + @loading_module = Dependencies::LoadingModule.new(STAGING_DIRECTORY) + Object.const_set(:Controllers, @loading_module) + end + def teardown + @loading_module.clear + Object.send :remove_const, :Controllers + end + + def test_setup + assert_kind_of Dependencies::LoadingModule, @loading_module + end + + def test_const_available + assert @loading_module.const_available?(:Admin) + assert @loading_module.const_available?(:ResourceController) + assert @loading_module.const_available?(:ContentController) + assert @loading_module.const_available?("ContentController") + + assert_equal false, @loading_module.const_available?(:AdminController) + assert_equal false, @loading_module.const_available?(:RandomName) + end + + def test_const_load_module + assert @loading_module.const_load!(:Admin) + assert_kind_of Module, @loading_module::Admin + assert_kind_of Dependencies::LoadingModule, @loading_module::Admin + end + + def test_const_load_controller + assert @loading_module.const_load!(:ContentController) + assert_kind_of Class, @loading_module::ContentController + end + + def test_const_load_nested_controller + assert @loading_module.const_load!(:Admin) + assert @loading_module::Admin.const_available?(:UserController) + assert @loading_module::Admin.const_load!(:UserController) + assert_kind_of Class, @loading_module::Admin::UserController + end + + def test_pretty_access + assert_kind_of Module, @loading_module::Admin + assert_kind_of Dependencies::LoadingModule, @loading_module::Admin + + assert_kind_of Class, @loading_module::Admin::UserController + assert_kind_of Class, @loading_module::Admin::AccessController + assert_kind_of Class, @loading_module::ResourceController + assert_kind_of Class, @loading_module::ContentController + end + + def test_missing_name + assert_raises(NameError) {@loading_module::PersonController} + assert_raises(NameError) {@loading_module::Admin::FishController} + end +end
\ No newline at end of file |