Sha256: ccc67df159c57660f8d183ba8b7309fd99a001f1c311e7a5e4a67a58af5b4ee5

Contents?: true

Size: 1.29 KB

Versions: 6

Compression:

Stored size: 1.29 KB

Contents

require File.dirname(__FILE__) + '/test_helper.rb'

class Plugin; end

require 'cache_advance/active_record_sweeper'

class CacheSetTest < Test::Unit::TestCase
  def setup
    @cache = CacheAdvance::CacheMock.new
    @cache_set = CacheAdvance::CacheSet.new(@cache)
  end
  
  def test_define_caches_should_yield_a_mapper
    @cache_set.define_caches do |mapper|
      assert_equal CacheAdvance::Mapper, mapper.class
    end
  end
  
  def test_should_apply_the_cache_if_found
    request = mock
    options = { :key => 'hippo' }
    @cache_set.add_named_cache(:kewl, {})
    @cache_set.named_caches[:kewl].expects(:value_for).with(request, options)
    @cache_set.apply(:kewl, request, options) { }
  end
  
  def test_apply_should_throw_exception_with_invalid_name
    assert_raise CacheAdvance::UnknownNamedCacheException do
      @cache_set.apply(:total_hack, mock(), {}) { }
    end
  end
  
  def test_should_pass_expiration_types_to_the_sweeper
    @cache_set.sweeper_type = CacheAdvance::ActiveRecordSweeper
    @cache_set.add_named_cache(:kewl, { :expiration_types => [:publication, :article] })
    @cache_set.add_named_cache(:howza, { :expiration_types => [:publication] })
    CacheAdvance::ActiveRecordSweeper.expects(:initialize_observed).with([:publication, :article])
    @cache_set.create_sweepers
  end
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
aub-cache_advance-1.1.2 test/cache_set_test.rb
aub-cache_advance-1.1.3 test/cache_set_test.rb
cache_advance-2.0.1 test/cache_set_test.rb
cache_advance-2.0.0 test/cache_set_test.rb
cache_advance-1.1.5 test/cache_set_test.rb
cache_advance-1.1.4 test/cache_set_test.rb