Methods
- C
- S
- T
Included Modules
Instance Public methods
cache_dir()
Link
setup()
Link
# File activesupport/test/caching_test.rb, line 564 def setup Dir.mkdir(cache_dir) unless File.exist?(cache_dir) @cache = ActiveSupport::Cache.lookup_store(:file_store, cache_dir, :expires_in => 60) @peek = ActiveSupport::Cache.lookup_store(:file_store, cache_dir, :expires_in => 60) @cache_with_pathname = ActiveSupport::Cache.lookup_store(:file_store, Pathname.new(cache_dir), :expires_in => 60) end
teardown()
Link
test_cleanup_removes_all_expired_entries()
Link
# File activesupport/test/caching_test.rb, line 612 def test_cleanup_removes_all_expired_entries time = Time.now @cache.write('foo', 'bar', :expires_in => 10) @cache.write('baz', 'qux') @cache.write('quux', 'corge', :expires_in => 20) Time.stubs(:now).returns(time + 15) @cache.cleanup assert !@cache.exist?('foo') assert @cache.exist?('baz') assert @cache.exist?('quux') end
test_delete_matched_when_cache_directory_does_not_exist()
Link
If nothing has been stored in the cache, there is a chance the cache directory does not yet exist Ensure delete_matched gracefully handles this case
test_key_transformation()
Link
test_key_transformation_max_filename_size()
Link
Because file systems have a maximum filename size, filenames > max size should be split in to directories If filename is 'AAAAB', where max size is 4, the returned path should be AAAA/B
# File activesupport/test/caching_test.rb, line 597 def test_key_transformation_max_filename_size key = "#{'A' * ActiveSupport::Cache::FileStore::FILENAME_MAX_SIZE}B" path = @cache.send(:key_file_path, key) assert path.split('/').all? { |dir_name| dir_name.size <= ActiveSupport::Cache::FileStore::FILENAME_MAX_SIZE} assert_equal 'B', File.basename(path) end
test_key_transformation_with_pathname()
Link
# File activesupport/test/caching_test.rb, line 589 def test_key_transformation_with_pathname FileUtils.touch(File.join(cache_dir, "foo")) key = @cache_with_pathname.send(:key_file_path, "views/index?id=1") assert_equal "views/index?id=1", @cache_with_pathname.send(:file_path_key, key) end