aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2006-09-04 06:02:16 +0000
committerJeremy Kemper <jeremy@bitsweat.net>2006-09-04 06:02:16 +0000
commit9f3ba03bc71e03814a090d8fcf1f8c4c3d5e4c49 (patch)
tree6cc254ee8d04f17ababcb63ea210d8da48a8b493 /activesupport/test
parent7269b086e1c3c6d43c97458efcc7c5c54a322b33 (diff)
downloadrails-9f3ba03bc71e03814a090d8fcf1f8c4c3d5e4c49.tar.gz
rails-9f3ba03bc71e03814a090d8fcf1f8c4c3d5e4c49.tar.bz2
rails-9f3ba03bc71e03814a090d8fcf1f8c4c3d5e4c49.zip
reloadable deprecation tests
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4979 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport/test')
-rw-r--r--activesupport/test/reloadable_test.rb84
1 files changed, 47 insertions, 37 deletions
diff --git a/activesupport/test/reloadable_test.rb b/activesupport/test/reloadable_test.rb
index 2ab19db77e..18120b39a7 100644
--- a/activesupport/test/reloadable_test.rb
+++ b/activesupport/test/reloadable_test.rb
@@ -1,38 +1,39 @@
require File.dirname(__FILE__) + '/abstract_unit'
-module ReloadableTestSandbox
-
- class AReloadableClass
- include Reloadable
- end
- class AReloadableClassWithSubclasses
- include Reloadable
- end
- class AReloadableSubclass < AReloadableClassWithSubclasses
- end
- class ANonReloadableSubclass < AReloadableClassWithSubclasses
- def self.reloadable?
- false
+ActiveSupport::Deprecation.silence do
+ module ReloadableTestSandbox
+ class AReloadableClass
+ include Reloadable
end
- end
- class AClassWhichDefinesItsOwnReloadable
- def self.reloadable?
- 10
+ class AReloadableClassWithSubclasses
+ include Reloadable
+ end
+ class AReloadableSubclass < AReloadableClassWithSubclasses
+ end
+ class ANonReloadableSubclass < AReloadableClassWithSubclasses
+ def self.reloadable?
+ false
+ end
+ end
+ class AClassWhichDefinesItsOwnReloadable
+ def self.reloadable?
+ 10
+ end
+ include Reloadable
end
- include Reloadable
- end
- class SubclassesReloadable
- include Reloadable::Subclasses
- end
- class ASubclassOfSubclassesReloadable < SubclassesReloadable
- end
+ class SubclassesReloadable
+ include Reloadable::Subclasses
+ end
+ class ASubclassOfSubclassesReloadable < SubclassesReloadable
+ end
- class AnOnlySubclassReloadableClassSubclassingAReloadableClass
- include Reloadable::Subclasses
- end
+ class AnOnlySubclassReloadableClassSubclassingAReloadableClass
+ include Reloadable::Subclasses
+ end
- class ASubclassofAOnlySubclassReloadableClassWhichWasSubclassingAReloadableClass < AnOnlySubclassReloadableClassSubclassingAReloadableClass
+ class ASubclassofAOnlySubclassReloadableClassWhichWasSubclassingAReloadableClass < AnOnlySubclassReloadableClassSubclassingAReloadableClass
+ end
end
end
@@ -48,13 +49,17 @@ class ReloadableTest < Test::Unit::TestCase
end
def test_only_subclass_reloadable
- assert ! ReloadableTestSandbox::SubclassesReloadable.reloadable?
- assert ReloadableTestSandbox::ASubclassOfSubclassesReloadable.reloadable?
+ assert_deprecated_reloadable do
+ assert !ReloadableTestSandbox::SubclassesReloadable.reloadable?
+ assert ReloadableTestSandbox::ASubclassOfSubclassesReloadable.reloadable?
+ end
end
def test_inside_hierarchy_only_subclass_reloadable
- assert ! ReloadableTestSandbox::AnOnlySubclassReloadableClassSubclassingAReloadableClass.reloadable?
- assert ReloadableTestSandbox::ASubclassofAOnlySubclassReloadableClassWhichWasSubclassingAReloadableClass.reloadable?
+ assert_deprecated_reloadable do
+ assert !ReloadableTestSandbox::AnOnlySubclassReloadableClassSubclassingAReloadableClass.reloadable?
+ assert ReloadableTestSandbox::ASubclassofAOnlySubclassReloadableClassWhichWasSubclassingAReloadableClass.reloadable?
+ end
end
def test_removable_classes
@@ -70,7 +75,8 @@ class ReloadableTest < Test::Unit::TestCase
SubclassesReloadable
)
- results = Reloadable.reloadable_classes
+ results = []
+ assert_deprecated_reloadable { results = Reloadable.reloadable_classes }
reloadables.each do |name|
assert results.include?(ReloadableTestSandbox.const_get(name)), "Expected #{name} to be reloadable"
end
@@ -81,11 +87,11 @@ class ReloadableTest < Test::Unit::TestCase
def test_including_reloadable_should_warn
c = Class.new
- assert_deprecated %r{Reloadable} do
+ assert_deprecated_reloadable do
c.send :include, Reloadable
end
- assert_deprecated { c.reloadable? }
+ assert_deprecated_reloadable { c.reloadable? }
end
def test_include_subclasses_should_warn
@@ -96,7 +102,7 @@ class ReloadableTest < Test::Unit::TestCase
assert_equal 1, deps.size
assert_match %r{Reloadable::Subclasses}, deps.first
- assert_deprecated { c.reloadable? }
+ assert_deprecated_reloadable { c.reloadable? }
end
def test_include_deprecated_should_not_warn
@@ -107,7 +113,11 @@ class ReloadableTest < Test::Unit::TestCase
assert_equal 0, deps.size
assert c.respond_to?(:reloadable?)
- assert_deprecated { c.reloadable? }
+ assert_deprecated_reloadable { c.reloadable? }
end
+ protected
+ def assert_deprecated_reloadable(&block)
+ assert_deprecated(/reloadable/, &block)
+ end
end