Methods
T
Instance Public methods
test_compress_values()
# File activesupport/test/caching_test.rb, line 1049
def test_compress_values
  value = "value" * 100
  entry = ActiveSupport::Cache::Entry.new(value, :compress => true, :compress_threshold => 1)
  assert_equal value, entry.value
  assert(value.bytesize > entry.size, "value is compressed")
end
test_expired()
# File activesupport/test/caching_test.rb, line 1039
def test_expired
  entry = ActiveSupport::Cache::Entry.new("value")
  assert !entry.expired?, 'entry not expired'
  entry = ActiveSupport::Cache::Entry.new("value", :expires_in => 60)
  assert !entry.expired?, 'entry not expired'
  time = Time.now + 61
  Time.stubs(:now).returns(time)
  assert entry.expired?, 'entry is expired'
end
test_non_compress_values()
# File activesupport/test/caching_test.rb, line 1056
def test_non_compress_values
  value = "value" * 100
  entry = ActiveSupport::Cache::Entry.new(value)
  assert_equal value, entry.value
  assert_equal value.bytesize, entry.size
end
test_restoring_compressed_version_4beta1_entries()
# File activesupport/test/caching_test.rb, line 1072
def test_restoring_compressed_version_4beta1_entries
  version_4beta1_entry = ActiveSupport::Cache::Entry.allocate
  version_4beta1_entry.instance_variable_set(:@v, Zlib::Deflate.deflate(Marshal.dump("hello")))
  version_4beta1_entry.instance_variable_set(:@c, true)
  entry = Marshal.load(Marshal.dump(version_4beta1_entry))
  assert_equal "hello", entry.value
end
test_restoring_expired_version_4beta1_entries()
# File activesupport/test/caching_test.rb, line 1080
def test_restoring_expired_version_4beta1_entries
  version_4beta1_entry = ActiveSupport::Cache::Entry.allocate
  version_4beta1_entry.instance_variable_set(:@v, "hello")
  version_4beta1_entry.instance_variable_set(:@x, Time.now.to_i - 1)
  entry = Marshal.load(Marshal.dump(version_4beta1_entry))
  assert_equal true, entry.expired?
  assert_equal "hello", entry.value
end
test_restoring_version_4beta1_entries()
# File activesupport/test/caching_test.rb, line 1063
def test_restoring_version_4beta1_entries
  version_4beta1_entry = ActiveSupport::Cache::Entry.allocate
  version_4beta1_entry.instance_variable_set(:@v, "hello")
  version_4beta1_entry.instance_variable_set(:@x, Time.now.to_i + 60)
  entry = Marshal.load(Marshal.dump(version_4beta1_entry))
  assert_equal "hello", entry.value
  assert_equal false, entry.expired?
end