cassette 1.2.3 → 1.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/cassette/cache.rb +9 -1
- data/lib/cassette/version.rb +1 -1
- data/spec/cassette/cache_spec.rb +50 -6
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 6541e55b06cc97ea1e68cd330af18791328e1cc72a9b04f9e93aa6e2f1032bc3
|
4
|
+
data.tar.gz: 765652bf692b0dd1c8b3ef1b6bd7eaac59a2da11d0fd5569e8c565b8963aed9a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a0d7e79d8ab928c6e3179bda6271eab2f6744662a37057b2dba53f92c1f5cc8b9486b6e86382f71cd2fddba069121ca49d392e28a7731db8b2c650e4dd77ebb0
|
7
|
+
data.tar.gz: 2721a7af21ff3a47ca13f495ae73c9c9e623bce36fb7d6d3418c5d69dac286760573aa2b653a791f25ab545abdaeea04e8a5824bdea9004f81f7bbca98eb4fe7
|
data/lib/cassette/cache.rb
CHANGED
@@ -8,7 +8,7 @@ end
|
|
8
8
|
|
9
9
|
module Cassette
|
10
10
|
module Cache
|
11
|
-
def backend
|
11
|
+
def self.backend
|
12
12
|
@backend ||= begin
|
13
13
|
if defined?(::Rails) && ::Rails.cache
|
14
14
|
::Rails.cache
|
@@ -20,6 +20,14 @@ module Cassette
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
+
def self.backend=(backend)
|
24
|
+
@backend = backend
|
25
|
+
end
|
26
|
+
|
27
|
+
def backend
|
28
|
+
@backend ||= Cassette::Cache.backend
|
29
|
+
end
|
30
|
+
|
23
31
|
attr_writer :backend
|
24
32
|
|
25
33
|
def uses_key(key)
|
data/lib/cassette/version.rb
CHANGED
data/spec/cassette/cache_spec.rb
CHANGED
@@ -2,27 +2,65 @@
|
|
2
2
|
|
3
3
|
describe Cassette::Cache do
|
4
4
|
subject do
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
cached()
|
6
|
+
end
|
7
|
+
|
8
|
+
after do
|
9
|
+
described_class.instance_variable_set(:@backend, nil)
|
10
|
+
end
|
11
|
+
|
12
|
+
describe '.backend' do
|
13
|
+
it 'defaults to rails backend' do
|
14
|
+
rails = double('Rails')
|
15
|
+
cache = double('cache_backend')
|
16
|
+
allow(rails).to receive(:cache).and_return(cache)
|
17
|
+
stub_const('Rails', rails)
|
18
|
+
|
19
|
+
expect(described_class.backend).to eql(cache)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe '.backend=' do
|
24
|
+
it 'provides a default backend for new instances' do
|
25
|
+
backend = double('backend')
|
26
|
+
expect(subject.backend).not_to eq(backend)
|
27
|
+
|
28
|
+
described_class.backend = backend
|
29
|
+
|
30
|
+
new_instance = cached()
|
31
|
+
expect(new_instance.backend).to eq(backend)
|
32
|
+
expect(new_instance.backend).not_to eq(subject.backend)
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'sets the default backend' do
|
36
|
+
backend = double('backend')
|
37
|
+
expect(described_class.backend).not_to eq(backend)
|
38
|
+
|
39
|
+
described_class.backend = backend
|
40
|
+
|
41
|
+
expect(described_class.backend).to eq(backend)
|
42
|
+
end
|
8
43
|
end
|
9
44
|
|
10
|
-
describe 'backend' do
|
45
|
+
describe '#backend' do
|
11
46
|
before { subject.backend = nil }
|
12
47
|
after { subject.backend = nil }
|
13
48
|
|
14
49
|
it 'sets the backend' do
|
15
50
|
backend = double('Backend')
|
51
|
+
|
16
52
|
subject.backend = backend
|
53
|
+
|
17
54
|
expect(subject.backend).to eql(backend)
|
18
55
|
end
|
19
56
|
|
20
57
|
it 'defaults to rails backend' do
|
21
58
|
rails = double('Rails')
|
22
|
-
|
59
|
+
cache = double('cache_backend')
|
60
|
+
allow(rails).to receive(:cache).and_return(cache)
|
23
61
|
stub_const('Rails', rails)
|
24
62
|
|
25
|
-
expect(subject.backend).to eql(
|
63
|
+
expect(subject.backend).to eql(cache)
|
26
64
|
end
|
27
65
|
end
|
28
66
|
|
@@ -34,4 +72,10 @@ describe Cassette::Cache do
|
|
34
72
|
subject.fetch('Generator', max_uses: 5) { generator.generate }
|
35
73
|
end
|
36
74
|
end
|
75
|
+
|
76
|
+
def cached
|
77
|
+
c = Class.new
|
78
|
+
c.send(:include, Cassette::Cache)
|
79
|
+
c.new
|
80
|
+
end
|
37
81
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cassette
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ricardo Hermida Ruiz
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-05-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -290,8 +290,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
290
290
|
- !ruby/object:Gem::Version
|
291
291
|
version: '0'
|
292
292
|
requirements: []
|
293
|
-
|
294
|
-
rubygems_version: 2.5.1
|
293
|
+
rubygems_version: 3.0.3
|
295
294
|
signing_key:
|
296
295
|
specification_version: 4
|
297
296
|
summary: Generates, validates and caches TGTs and STs
|