module DescendantsTrackerTestCases
Constants
- ALL
Public Instance Methods
test_clear()
click to toggle source
# File activesupport/test/descendants_tracker_test_cases.rb, line 36 def test_clear mark_as_autoloaded(*ALL) do ActiveSupport::DescendantsTracker.clear ALL.each do |k| assert ActiveSupport::DescendantsTracker.descendants(k).empty? end end end
test_descendants()
click to toggle source
# File activesupport/test/descendants_tracker_test_cases.rb, line 24 def test_descendants assert_equal_sets [Child1, Grandchild1, Grandchild2, Child2], Parent.descendants assert_equal_sets [Grandchild1, Grandchild2], Child1.descendants assert_equal_sets [], Child2.descendants end
test_direct_descendants()
click to toggle source
# File activesupport/test/descendants_tracker_test_cases.rb, line 30 def test_direct_descendants assert_equal_sets [Child1, Child2], Parent.direct_descendants assert_equal_sets [Grandchild1, Grandchild2], Child1.direct_descendants assert_equal_sets [], Child2.direct_descendants end
Private Instance Methods
assert_equal_sets(expected, actual)
click to toggle source
# File activesupport/test/descendants_tracker_test_cases.rb, line 47 def assert_equal_sets(expected, actual) assert_equal Set.new(expected), Set.new(actual) end
mark_as_autoloaded(*klasses) { || ... }
click to toggle source
# File activesupport/test/descendants_tracker_test_cases.rb, line 51 def mark_as_autoloaded(*klasses) # If ActiveSupport::Dependencies is not loaded, forget about autoloading. # This allows using AS::DescendantsTracker without AS::Dependencies. if defined? ActiveSupport::Dependencies old_autoloaded = ActiveSupport::Dependencies.autoloaded_constants.dup ActiveSupport::Dependencies.autoloaded_constants = klasses.map(&:name) end old_descendants = ActiveSupport::DescendantsTracker.class_eval("@@direct_descendants").dup old_descendants.each { |k, v| old_descendants[k] = v.dup } yield ensure ActiveSupport::Dependencies.autoloaded_constants = old_autoloaded if defined? ActiveSupport::Dependencies ActiveSupport::DescendantsTracker.class_eval("@@direct_descendants").replace(old_descendants) end