Sha256: 26fb37b08208cb19eeb561ef0a8ce27aafd653a93460f487abcfb56df63d5418

Contents?: true

Size: 1.17 KB

Versions: 6

Compression:

Stored size: 1.17 KB

Contents

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

class Hack
end

class MapperTest < Test::Unit::TestCase
  
  def setup
    @cache = CacheAdvance::CacheMock.new
    @cache_set = CacheAdvance::CacheSet.new(@cache)
    @mapper = CacheAdvance::Mapper.new(@cache_set)
  end
  
  def test_qualifier
    @mapper.qualifier(:thirty_four) do
      34
    end
    assert_equal 1, @cache_set.qualifiers.size
    assert_equal 34, @cache_set.qualifiers[:thirty_four].call
  end
  
  def test_plugin_from_symbol
    @mapper.plugin(:hack)
    assert_equal 1, @cache_set.plugins.size
    assert_equal Hack, @cache_set.plugins.first.class
  end
  
  def test_plugin_from_class
    @mapper.plugin(Hack)
    assert_equal 1, @cache_set.plugins.size
    assert_equal Hack, @cache_set.plugins.first.class
  end
  
  def test_plugin_from_object
    hack = Hack.new
    @mapper.plugin(hack)
    assert_equal 1, @cache_set.plugins.size
    assert_equal hack, @cache_set.plugins.first
  end
  
  def test_adding_caches_through_method_missing
    @mapper.say_what :option => 2
    assert_equal 1, @cache_set.named_caches.size
    assert_equal CacheAdvance::NamedCache, @cache_set.named_caches[:say_what].class
  end
end

Version data entries

6 entries across 6 versions & 2 rubygems

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