Sha256: b7e1029cbe1e7dbb50e98726ed7808f4ed0be997b4af751abf37c9822e176d97

Contents?: true

Size: 1.01 KB

Versions: 3

Compression:

Stored size: 1.01 KB

Contents

# -*- encoding: utf-8 -*-

require 'minitest/autorun'
require 'webgen/cache'

class TestCache < MiniTest::Unit::TestCase

  def setup
    @cache = Webgen::Cache.new
  end

  def dump_and_restore
    data = @cache.dump
    setup
    @cache.restore(data)
  end

  def test_standard_cache
    @cache[:key] = :value
    assert_equal(:value, @cache[:key])
    dump_and_restore
    assert_equal(:value, @cache[:key])
    @cache[:key] = :newvalue
    assert_equal(:value, @cache[:key])
    dump_and_restore
    assert_equal(:newvalue, @cache[:key])
  end

  def test_permanent_cache
    @cache.permanent[:key] = :value
    assert_equal(:value, @cache.permanent[:key])
    dump_and_restore
    assert_equal(:value, @cache.permanent[:key])
  end

  def test_volatile_cache
    @cache.volatile[:key] = :value
    assert_equal(:value, @cache.volatile[:key])
    dump_and_restore
    assert_equal(nil, @cache.volatile[:key])

    @cache.volatile[:key] = :value
    @cache.reset_volatile_cache
    assert_equal(nil, @cache.volatile[:key])
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
webgen-1.0.0.beta3 test/webgen/test_cache.rb
webgen-1.0.0.beta2 test/webgen/test_cache.rb
webgen-1.0.0.beta1 test/webgen/test_cache.rb