Sha256: 2da7a6f5926de39fe35b9d8014b1cb85639963df7f7cb615602d3ff8233981ab
Contents?: true
Size: 1.69 KB
Versions: 2
Compression:
Stored size: 1.69 KB
Contents
#= require spec_helper #= require modularity/tools/cache describe 'Cache', -> cache = null beforeEach -> cache = new modularity.Cache() describe 'constructor', -> it 'initializes with an empty cache', -> cache.cache.should.eql({}) describe 'add', -> it 'stores the given data in the cache', -> cache.add('foo', 'bar') cache.cache.should.eql({'foo': 'bar'}) it 'overwrites existing entries', -> cache.cache = {'foo', 'bar'} cache.add 'foo', 'new' (cache.cache['foo']).should.be.equal('new') describe 'get', -> it "returns undefined if the entry doesn't exist", -> expect(cache.get('zonk')).to.be.undefined it "returns the entry if it exists", -> cache.add 'foo', 'bar' cache.get('foo').should.equal('bar') describe 'getMany', -> result = null beforeEach -> cache.add('one', 1) cache.add('two', 2) result = cache.getMany ['one', 'three'] it "returns the values that exist in the 'found' structure", -> result.found.should.eql({'one': 1}) it "returns the values that don't exist in the 'missing' structure", -> result.missing.should.eql(['three']) describe 'length', -> it 'returns 0 for empty cache', -> cache.length().should.equal 0 it 'returns the number of objects in the cache', -> cache.add('foo', 'bar') cache.add('fooz', 'baz') cache.length().should.equal(2) describe 'replaceAll', -> it 'replaces the whole cache with the given data', -> cache.add 'one', 1 cache.replaceAll {'one': 2, two: 3} cache.length().should.equal(2) cache.get('one').should.equal(2) cache.get('two').should.equal(3)
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
modularity-rails-0.11.0 | demo/spec/javascripts/tools/cache_spec.coffee |
modularity-rails-0.10.0 | demo/spec/javascripts/tools/cache_spec.coffee |