Sha256: 14b1d31f85b03d41503784e3b54b9672211de40a0f64622b4595e47bdb878ef5

Contents?: true

Size: 1.04 KB

Versions: 6

Compression:

Stored size: 1.04 KB

Contents

require File.join(File.dirname(__FILE__), 'test_helper')

class KeyTest < Test::Unit::TestCase

  def setup
    @cache = CacheAdvance::CacheMock.new
    @cache_set = CacheAdvance::CacheSet.new(@cache)
  end

  def test_should_symbolize_the_cache_name
    @cache_set.add_named_cache('booya', {})
    assert_nothing_raised do
      @cache_set.apply(:booya, nil, :key => 'abc') do
        '123'
      end
    end
  end

  def test_should_symbolize_the_cache_name_when_using_it 
    @cache_set.add_named_cache(:booya, {})
    assert_nothing_raised do
      @cache_set.apply('booya', nil, :key => 'abc') do
        '123'
      end
    end
  end

  def test_should_remove_whitespace_from_the_key
    @cache_set.add_named_cache(:booya, {})
    result = @cache_set.apply(:booya, nil, :key => 'abc def') do
      '123'
    end
    assert_equal '123', @cache.get('booya/abcdef/[]')
    assert_equal '123', result
    @cache.set('booya/abcdef/[]', '234')
    result = @cache_set.apply(:booya, nil, :key => 'abc def') do
      '123'
    end
    assert_equal '234', result
  end
end

Version data entries

6 entries across 6 versions & 2 rubygems

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