Permalink
Browse files

added some (pointless) test cases to dependency loading, the more the…

… merrier

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3537 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent 9474fe7 commit 6fa5b7b304ae9d4a56232e436feec8cc691ad92a Tobias Lütke committed Feb 4, 2006
Showing with 39 additions and 8 deletions.
  1. +2 −0 activesupport/test/autoloading_fixtures/a/c/e/f.rb
  2. +37 −8 activesupport/test/dependencies_test.rb
@@ -0,0 +1,2 @@
+class A::C::E::F
+end
@@ -106,14 +106,43 @@ def test_as_load_path
end
def test_module_loading
- $LOAD_PATH.unshift "#{File.dirname(__FILE__)}/autoloading_fixtures"
- old_mechanism, Dependencies.mechanism = Dependencies.mechanism, :load
+ begin
+ $LOAD_PATH.unshift "#{File.dirname(__FILE__)}/autoloading_fixtures"
+ old_mechanism, Dependencies.mechanism = Dependencies.mechanism, :load
+
+ assert_kind_of Module, A
+ assert_kind_of Class, A::B
+ assert_kind_of Class, A::C::D
+ assert_kind_of Class, A::C::E::F
+ ensure
+ $LOAD_PATH.shift
+ Dependencies.mechanism = old_mechanism
+ end
+ end
+
+ def test_non_existing_cost_raises_nameerrror
+ begin
+ $LOAD_PATH.unshift "#{File.dirname(__FILE__)}/autoloading_fixtures"
+ old_mechanism, Dependencies.mechanism = Dependencies.mechanism, :load
+ assert_raises(NameError) do
+ DoesNotExist
+ end
+
+ assert_raises(NameError) do
+ NoModule::DoesNotExist
+ end
+
+ assert_raises(NameError) do
+ A::DoesNotExist
+ end
+
+ assert_raises(NameError) do
+ A::B::DoesNotExist
+ end
+ ensure
+ $LOAD_PATH.shift
+ Dependencies.mechanism = old_mechanism
+ end
- assert_kind_of Module, A
- assert_kind_of Class, A::B
- assert_kind_of Class, A::C::D
- ensure
- $LOAD_PATH.shift
- Dependencies.mechanism = old_mechanism
end
end

0 comments on commit 6fa5b7b

Please sign in to comment.