garner 0.5.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -30
- data/.rubocop_todo.yml +49 -0
- data/.travis.yml +2 -0
- data/CHANGELOG.md +6 -0
- data/Gemfile +1 -1
- data/README.md +2 -2
- data/garner.gemspec +2 -2
- data/lib/garner/cache.rb +1 -1
- data/lib/garner/strategies/binding/key/binding_index.rb +1 -1
- data/lib/garner/version.rb +1 -1
- data/spec/garner/cache/context_spec.rb +4 -4
- data/spec/garner/cache/identity_spec.rb +6 -6
- data/spec/garner/cache_spec.rb +14 -6
- data/spec/garner/config_spec.rb +1 -1
- data/spec/garner/mixins/mongoid/document_spec.rb +12 -12
- data/spec/garner/mixins/mongoid/identity_spec.rb +25 -25
- data/spec/garner/mixins/rack_spec.rb +6 -6
- data/spec/garner/strategies/binding/invalidation/binding_index_spec.rb +1 -1
- data/spec/garner/strategies/binding/invalidation/touch_spec.rb +3 -3
- data/spec/garner/strategies/binding/key/binding_index_spec.rb +44 -44
- data/spec/garner/strategies/binding/key/cache_key_spec.rb +2 -2
- data/spec/garner/strategies/binding/key/safe_cache_key_spec.rb +12 -12
- data/spec/garner/strategies/context/key/caller_spec.rb +17 -17
- data/spec/garner/strategies/context/key/jsonp_spec.rb +2 -2
- data/spec/garner/strategies/context/key/request_get_spec.rb +3 -3
- data/spec/garner/strategies/context/key/request_path_spec.rb +3 -3
- data/spec/garner/strategies/context/key/request_post_spec.rb +3 -3
- data/spec/garner/version_spec.rb +2 -2
- data/spec/integration/active_record_spec.rb +4 -4
- data/spec/integration/grape_spec.rb +1 -1
- data/spec/integration/mongoid_spec.rb +57 -57
- data/spec/integration/rack_spec.rb +7 -7
- data/spec/integration/sinatra_spec.rb +1 -1
- data/spec/shared/binding_invalidation_strategy.rb +1 -1
- data/spec/shared/binding_key_strategy.rb +4 -4
- data/spec/shared/conditional_get.rb +13 -13
- data/spec/shared/context_key_strategy.rb +2 -2
- data/spec/spec_helper.rb +1 -0
- metadata +8 -7
@@ -2,7 +2,7 @@
|
|
2
2
|
# implement apply(binding) and force_apply(binding)
|
3
3
|
shared_examples_for 'Garner::Strategies::Binding::Invalidation strategy' do
|
4
4
|
it 'inherits from Garner::Strategies::Binding::Invalidation::Base' do
|
5
|
-
subject.new.
|
5
|
+
expect(subject.new).to be_a(Garner::Strategies::Binding::Invalidation::Base)
|
6
6
|
end
|
7
7
|
|
8
8
|
describe 'apply' do
|
@@ -6,13 +6,13 @@ shared_examples_for 'Garner::Strategies::Binding::Key strategy' do
|
|
6
6
|
end
|
7
7
|
|
8
8
|
it 'inherits from Garner::Strategies::Binding::Key::Base' do
|
9
|
-
subject.new.
|
9
|
+
expect(subject.new).to be_a(Garner::Strategies::Binding::Key::Base)
|
10
10
|
end
|
11
11
|
|
12
12
|
describe 'given a known binding' do
|
13
13
|
it 'returns a valid cache key' do
|
14
14
|
known_bindings.each do |binding|
|
15
|
-
subject.apply(binding).
|
15
|
+
expect(subject.apply(binding)).to be_a(String)
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
@@ -20,7 +20,7 @@ shared_examples_for 'Garner::Strategies::Binding::Key strategy' do
|
|
20
20
|
known_bindings.each do |binding|
|
21
21
|
key1 = subject.apply(binding)
|
22
22
|
key2 = subject.apply(binding)
|
23
|
-
key1.
|
23
|
+
expect(key1).to eq key2
|
24
24
|
end
|
25
25
|
end
|
26
26
|
end
|
@@ -28,7 +28,7 @@ shared_examples_for 'Garner::Strategies::Binding::Key strategy' do
|
|
28
28
|
describe 'given an unknown binding' do
|
29
29
|
it 'returns a nil cache key' do
|
30
30
|
unknown_bindings.each do |binding|
|
31
|
-
subject.apply(binding).
|
31
|
+
expect(subject.apply(binding)).to be_nil
|
32
32
|
end
|
33
33
|
end
|
34
34
|
end
|
@@ -14,35 +14,35 @@ shared_examples_for 'Rack::ConditionalGet server' do
|
|
14
14
|
|
15
15
|
it "writes the cached object's ETag from binding" do
|
16
16
|
get '/'
|
17
|
-
last_response.headers['ETag'].length.
|
17
|
+
expect(last_response.headers['ETag'].length).to eq 32 + 2
|
18
18
|
end
|
19
19
|
|
20
20
|
it 'sends a 304 response if content has not changed (If-None-Match)' do
|
21
21
|
get '/'
|
22
|
-
last_response.status.
|
23
|
-
last_response.headers['ETag'].
|
22
|
+
expect(last_response.status).to eq 200
|
23
|
+
expect(last_response.headers['ETag']).to eq %("#{etag_for(last_response.body)}")
|
24
24
|
get '/', {}, 'HTTP_IF_NONE_MATCH' => last_response.headers['ETag']
|
25
|
-
last_response.status.
|
25
|
+
expect(last_response.status).to eq 304
|
26
26
|
end
|
27
27
|
|
28
28
|
it 'sends a 200 response if content has changed (If-None-Match)' do
|
29
29
|
get '/'
|
30
|
-
last_response.status.
|
31
|
-
get '/', {}, 'HTTP_IF_NONE_MATCH' => %
|
32
|
-
last_response.status.
|
30
|
+
expect(last_response.status).to eq 200
|
31
|
+
get '/', {}, 'HTTP_IF_NONE_MATCH' => %("#{etag_for('foobar')}")
|
32
|
+
expect(last_response.status).to eq 200
|
33
33
|
end
|
34
34
|
|
35
35
|
it 'sends a 200 response if content has changed (valid If-Modified-Since but invalid If-None-Match)' do
|
36
36
|
get '/'
|
37
|
-
last_response.status.
|
38
|
-
get '/', {}, 'HTTP_IF_MODIFIED_SINCE' => (Time.now + 1).httpdate, 'HTTP_IF_NONE_MATCH' => %
|
39
|
-
last_response.status.
|
37
|
+
expect(last_response.status).to eq 200
|
38
|
+
get '/', {}, 'HTTP_IF_MODIFIED_SINCE' => (Time.now + 1).httpdate, 'HTTP_IF_NONE_MATCH' => %("#{etag_for(last_response.body)}")
|
39
|
+
expect(last_response.status).to eq 200
|
40
40
|
end
|
41
41
|
|
42
42
|
it 'adds Cache-Control, Pragma and Expires headers' do
|
43
43
|
get '/'
|
44
|
-
last_response.headers['Cache-Control'].split(', ').sort.
|
45
|
-
last_response.headers['Pragma'].
|
46
|
-
Time.parse(last_response.headers['Expires']).
|
44
|
+
expect(last_response.headers['Cache-Control'].split(', ').sort).to eq %w(max-age=0 must-revalidate private)
|
45
|
+
expect(last_response.headers['Pragma']).to be_nil
|
46
|
+
expect(Time.parse(last_response.headers['Expires'])).to be < Time.now
|
47
47
|
end
|
48
48
|
end
|
@@ -6,7 +6,7 @@ shared_examples_for 'Garner::Strategies::Context::Key strategy' do
|
|
6
6
|
end
|
7
7
|
|
8
8
|
it 'inherits from Garner::Strategies::Context::Key::Base' do
|
9
|
-
subject.new.
|
9
|
+
expect(subject.new).to be_a(Garner::Strategies::Context::Key::Base)
|
10
10
|
end
|
11
11
|
|
12
12
|
it 'requires a Garner::Cache::Identity' do
|
@@ -19,6 +19,6 @@ shared_examples_for 'Garner::Strategies::Context::Key strategy' do
|
|
19
19
|
|
20
20
|
it 'returns a Garner::Cache::Identity' do
|
21
21
|
modified_identity = subject.apply(@cache_identity, self)
|
22
|
-
modified_identity.
|
22
|
+
expect(modified_identity).to eq @cache_identity
|
23
23
|
end
|
24
24
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: garner
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Doubrovkine
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-11-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rack
|
@@ -87,14 +87,14 @@ dependencies:
|
|
87
87
|
requirements:
|
88
88
|
- - ~>
|
89
89
|
- !ruby/object:Gem::Version
|
90
|
-
version: '
|
90
|
+
version: '3.1'
|
91
91
|
type: :development
|
92
92
|
prerelease: false
|
93
93
|
version_requirements: !ruby/object:Gem::Requirement
|
94
94
|
requirements:
|
95
95
|
- - ~>
|
96
96
|
- !ruby/object:Gem::Version
|
97
|
-
version: '
|
97
|
+
version: '3.1'
|
98
98
|
- !ruby/object:Gem::Dependency
|
99
99
|
name: bundler
|
100
100
|
requirement: !ruby/object:Gem::Requirement
|
@@ -255,14 +255,14 @@ dependencies:
|
|
255
255
|
requirements:
|
256
256
|
- - '='
|
257
257
|
- !ruby/object:Gem::Version
|
258
|
-
version: 0.
|
258
|
+
version: 0.27.1
|
259
259
|
type: :development
|
260
260
|
prerelease: false
|
261
261
|
version_requirements: !ruby/object:Gem::Requirement
|
262
262
|
requirements:
|
263
263
|
- - '='
|
264
264
|
- !ruby/object:Gem::Version
|
265
|
-
version: 0.
|
265
|
+
version: 0.27.1
|
266
266
|
description:
|
267
267
|
email:
|
268
268
|
- dblock@dblock.org
|
@@ -279,6 +279,7 @@ files:
|
|
279
279
|
- .gitignore
|
280
280
|
- .rspec
|
281
281
|
- .rubocop.yml
|
282
|
+
- .rubocop_todo.yml
|
282
283
|
- .travis.yml
|
283
284
|
- CHANGELOG.md
|
284
285
|
- CONTRIBUTING.md
|
@@ -370,7 +371,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
370
371
|
version: '0'
|
371
372
|
requirements: []
|
372
373
|
rubyforge_project:
|
373
|
-
rubygems_version: 2.
|
374
|
+
rubygems_version: 2.1.11
|
374
375
|
signing_key:
|
375
376
|
specification_version: 4
|
376
377
|
summary: Garner is a cache layer for Ruby and Rack applications, supporting model
|