mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
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
This commit is contained in:
parent
9474fe72dd
commit
6fa5b7b304
2 changed files with 39 additions and 8 deletions
2
activesupport/test/autoloading_fixtures/a/c/e/f.rb
Normal file
2
activesupport/test/autoloading_fixtures/a/c/e/f.rb
Normal file
|
@ -0,0 +1,2 @@
|
|||
class A::C::E::F
|
||||
end
|
|
@ -106,14 +106,43 @@ class DependenciesTest < Test::Unit::TestCase
|
|||
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
|
||||
|
|
Loading…
Reference in a new issue