Skip to content
Myr

spec.plugins.cache.js

This file

Path

spec/spec.plugins.cache.js

171 lines · 4.5 KiB · JavaScript

Last changed by

Merge branch 'master' of http://github.com/visionmedia/expressGuillermo Rauchbefore adoption8ef6a0b

History of this file

Take it

The walk stopped after 200 commits: lines older than fbf547d point at it.

Added Session classvisionmediabefore adoptionfbf547d

lines 1–21why, one step back
1
2describe 'Express'3 before_each4 reset()5 use(require('express/plugins/cache').Cache)6 cache = require('express/plugins/cache')7 end8 9 describe 'Cache'10 describe 'Request'11 describe '#cache'12 it 'should use memory store by default'13 get('/item', function(){14 return this.cache.toString()15 })16 get('/item').body.should.eql '[Memory Store]'17 end18 end19 end20 end21

Merge branch 'cache-lifetime'visionmediabefore adoption5ce1306

lines 22–29why, one step back
22 describe 'cache Store.Memory'
23 before_each24 store = new cache.Store.Memory25 end26 27 describe '#toString()'28 it 'should return [Memory Store]'29 store.toString().should.eql '[Memory Store]'

Added Session classvisionmediabefore adoptionfbf547d

line 30why, one step back
30 end

Merge branch 'cache-lifetime'visionmediabefore adoption5ce1306

lines 31–35why, one step back
31 end
32 33 describe '#set()'34 describe 'given a key and value'35 it 'should set the cache data'

Merge branch 'async-cache'visionmediabefore adoption7606f1b

lines 36–42why, one step back
36 var result
37 store.set('foo', 'bar', function(){38 store.get('foo', function(val){39 result = val40 })41 })42 result.should.eql 'bar'

Added Session classvisionmediabefore adoptionfbf547d

lines 43–44why, one step back
43 end
44

Merge branch 'master' of http://github.com/visionmedia/expressGuillermo Rauchbefore adoption8ef6a0b

lines 45–59why, one step back
45 it 'should work with regexp special characters'
46 var result,47 result248 store.set('page:/users/1/comments?page=2', 'html', function(){49 store.get('page:/users/1/comments?page=2', function(val){50 result = val51 store.get('page:*', function(vals){52 result2 = vals53 })54 })55 })56 result.should.eql 'html'57 result2.should.eql { 'page:/users/1/comments?page=2': 'html' }58 end59

Merge branch 'cache-lifetime'visionmediabefore adoption5ce1306

line 60why, one step back
60 it 'should override existing data'

Merge branch 'async-cache'visionmediabefore adoption7606f1b

lines 61–69why, one step back
61 var result
62 store.set('foo', 'bar', function(){63 store.set('foo', 'baz', function(){64 store.get('foo', function(val){65 result = val66 })67 })68 })69 result.should.eql 'baz'

Added Session classvisionmediabefore adoptionfbf547d

lines 70–72why, one step back
70 end
71 end72

Merge branch 'cache-lifetime'visionmediabefore adoption5ce1306

lines 73–75why, one step back
73 describe 'given an abitrary key'
74 it 'should throw an error'75 -{ store.set({}, 'foo') }.should.throw_error

Added Session classvisionmediabefore adoptionfbf547d

line 76why, one step back
76 end

Merge branch 'cache-lifetime'visionmediabefore adoption5ce1306

lines 77–80why, one step back
77 end
78 79 describe 'given an abitrary value'80 it 'should serialize as JSON'

Merge branch 'async-cache'visionmediabefore adoption7606f1b

lines 81–85why, one step back
81 var result
82 store.set('user', { name: 'tj' }, function(val){83 result = val84 })85 result.should.eql { name: 'tj' }

Merge branch 'cache-lifetime'visionmediabefore adoption5ce1306

lines 86–92why, one step back
86 end
87 end88 end89 90 describe '#get()'91 describe 'given a key'92 it 'should unserialize JSON data'

Merge branch 'async-cache'visionmediabefore adoption7606f1b

lines 93–99why, one step back
93 var result
94 store.set('user', { name: 'tj' }, function(){95 store.get('user', function(val){96 result = val97 })98 })99 result.should.eql { name: 'tj' }

Added Session classvisionmediabefore adoptionfbf547d

lines 100–102why, one step back
100 end
101 end102

Merge branch 'cache-lifetime'visionmediabefore adoption5ce1306

line 103why, one step back
103 describe 'given wildcards'

Merge branch 'async-cache'visionmediabefore adoption7606f1b

lines 104–115why, one step back
104 it 'should pass a set of caches'
105 var result106 store.set('user:1', 'a', function(){107 store.set('user:2', 'b', function(){108 store.set('foo', 'bar', function(){109 store.get('user:*', function(val){110 result = val111 })112 })113 })114 })115 result.should.eql { 'user:1': 'a', 'user:2': 'b' }

Added Session classvisionmediabefore adoptionfbf547d

line 116why, one step back
116 end

Merge branch 'cache-lifetime'visionmediabefore adoption5ce1306

lines 117–122why, one step back
117 end
118 end119 120 describe '#clear()'121 describe 'given a key'122 it 'should delete previous data'

Merge branch 'async-cache'visionmediabefore adoption7606f1b

lines 123–131why, one step back
123 var result
124 store.set('foo', 'bar', function(){125 store.clear('foo', function(){126 store.get('foo', function(val){127 result = val128 })129 })130 })131 result.should.be_null

Added Session classvisionmediabefore adoptionfbf547d

lines 132–134why, one step back
132 end
133 end134

Merge branch 'cache-lifetime'visionmediabefore adoption5ce1306

lines 135–136why, one step back
135 describe 'given wildcards'
136 it 'should clear a set of caches'

Merge branch 'async-cache'visionmediabefore adoption7606f1b

lines 137–150why, one step back
137 var results = []
138 store.set('user:one', '1', function(){139 store.set('user:two', '2', function(){140 store.clear('user:*', function(){141 store.get('user:one', function(val){142 results.push(val)143 store.get('user:two', function(val){144 results.push(val)145 })146 })147 })148 }) 149 })150 results.should.eql [null, null]

Merge branch 'cache-lifetime'visionmediabefore adoption5ce1306

lines 151–157why, one step back
151 end
152 end153 end154 155 describe '#reap()'156 it 'should destroy caches older than the given age in milliseconds'157 store.set('user:one', '1')

Merge branch 'async-cache'visionmediabefore adoption7606f1b

line 158why, one step back
158 store.data['user:one'].created = Number((5).minutes.ago)

Merge branch 'cache-lifetime'visionmediabefore adoption5ce1306

line 159why, one step back
159 store.set('user:two', '2')

Merge branch 'async-cache'visionmediabefore adoption7606f1b

lines 160–167why, one step back
160 store.data['user:two'].created = Number((2).seconds.ago)
161 store.reap((1).minute)162 store.get('user:one', function(val){163 val.should.be_null164 })165 store.get('user:two', function(val){166 val.should.not.be_null167 })

Merge branch 'cache-lifetime'visionmediabefore adoption5ce1306

line 168why, one step back
168 end

Added Session classvisionmediabefore adoptionfbf547d

lines 169–171why, one step back
169 end
170 end171end