aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/cache/behaviors/autoloading_cache_behavior.rb
diff options
context:
space:
mode:
authorJeremy Daer <jeremydaer@gmail.com>2017-06-10 01:07:40 -0700
committerJeremy Daer <jeremydaer@gmail.com>2017-06-10 01:23:10 -0700
commitddea3164250ed5f3886f07cbbc01727fd6dff99c (patch)
tree44fedca93656cf9b74f3bc3268cba5f3c129fa58 /activesupport/test/cache/behaviors/autoloading_cache_behavior.rb
parent57cfd45b167c99bd5737f14e3c3805dc38c668ce (diff)
downloadrails-ddea3164250ed5f3886f07cbbc01727fd6dff99c.tar.gz
rails-ddea3164250ed5f3886f07cbbc01727fd6dff99c.tar.bz2
rails-ddea3164250ed5f3886f07cbbc01727fd6dff99c.zip
Split up the cache test suite so it's easier to understand and extend (#29404)
Split up the caching tests as prep for adding a new cache store. Slices the mega test/caching_test.rb into behavior modules, concrete store tests, and cross-cutting store tests. Considering moving cache store behavior modules into lib/ so they may be used for acceptance testing by third parties.
Diffstat (limited to 'activesupport/test/cache/behaviors/autoloading_cache_behavior.rb')
-rw-r--r--activesupport/test/cache/behaviors/autoloading_cache_behavior.rb41
1 files changed, 41 insertions, 0 deletions
diff --git a/activesupport/test/cache/behaviors/autoloading_cache_behavior.rb b/activesupport/test/cache/behaviors/autoloading_cache_behavior.rb
new file mode 100644
index 0000000000..5f8af331f6
--- /dev/null
+++ b/activesupport/test/cache/behaviors/autoloading_cache_behavior.rb
@@ -0,0 +1,41 @@
+require "dependencies_test_helpers"
+
+module AutoloadingCacheBehavior
+ include DependenciesTestHelpers
+
+ def test_simple_autoloading
+ with_autoloading_fixtures do
+ @cache.write("foo", EM.new)
+ end
+
+ remove_constants(:EM)
+ ActiveSupport::Dependencies.clear
+
+ with_autoloading_fixtures do
+ assert_kind_of EM, @cache.read("foo")
+ end
+
+ remove_constants(:EM)
+ ActiveSupport::Dependencies.clear
+ end
+
+ def test_two_classes_autoloading
+ with_autoloading_fixtures do
+ @cache.write("foo", [EM.new, ClassFolder.new])
+ end
+
+ remove_constants(:EM, :ClassFolder)
+ ActiveSupport::Dependencies.clear
+
+ with_autoloading_fixtures do
+ loaded = @cache.read("foo")
+ assert_kind_of Array, loaded
+ assert_equal 2, loaded.size
+ assert_kind_of EM, loaded[0]
+ assert_kind_of ClassFolder, loaded[1]
+ end
+
+ remove_constants(:EM, :ClassFolder)
+ ActiveSupport::Dependencies.clear
+ end
+end