rspec-rails-caching 0.2.0 → 0.2.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.
data/lib/rspec-rails-caching.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
require_relative 'rspec-rails-caching/version'
|
2
|
+
require_relative 'rspec-rails-caching/matchers'
|
3
|
+
require_relative 'rspec-rails-caching/test_store'
|
4
|
+
require_relative 'rspec-rails-caching/extensions/action_controller'
|
5
5
|
|
6
6
|
module RSpecRailsCaching
|
7
7
|
|
8
8
|
RSpec.configure do |config|
|
9
9
|
if ActionController::Base.perform_caching
|
10
10
|
silence_warnings do
|
11
|
-
Object.const_set :RAILS_CACHE, TestStore.new(true)
|
11
|
+
Object.const_set :RAILS_CACHE, TestStore.new(do_read_cache: true)
|
12
12
|
end
|
13
13
|
ActionController::Base.cache_store = RAILS_CACHE
|
14
14
|
ActionController::Base.class_eval do
|
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
require_relative 'extensions/action_controller/base'
|
@@ -1,4 +1,4 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
require_relative 'matchers/cache'
|
2
|
+
require_relative 'matchers/expire'
|
3
|
+
require_relative 'matchers/cache_page'
|
4
|
+
require_relative 'matchers/expire_page'
|
@@ -5,18 +5,18 @@ module RSpecRailsCaching
|
|
5
5
|
attr_reader :expired
|
6
6
|
attr_reader :expiration_patterns
|
7
7
|
attr_reader :data
|
8
|
-
attr_accessor :
|
8
|
+
attr_accessor :options
|
9
9
|
attr_reader :cached_pages
|
10
10
|
attr_reader :expired_pages
|
11
11
|
|
12
12
|
attr_accessor :context
|
13
13
|
|
14
|
-
def initialize(
|
14
|
+
def initialize(options = nil)
|
15
|
+
@options = options ? options.dup : {do_read_cache: false}
|
15
16
|
@data = {}
|
16
17
|
@cached = []
|
17
18
|
@expired = []
|
18
19
|
@expiration_patterns = []
|
19
|
-
@read_cache = do_read_cache
|
20
20
|
@cached_pages = []
|
21
21
|
@expired_pages = []
|
22
22
|
end
|
@@ -28,20 +28,20 @@ module RSpecRailsCaching
|
|
28
28
|
@expiration_patterns.clear
|
29
29
|
end
|
30
30
|
|
31
|
-
def read_entry(name, options =
|
32
|
-
|
31
|
+
def read_entry(name, options = {})
|
32
|
+
options[:do_read_cache] ? @data[name] : nil
|
33
33
|
end
|
34
34
|
|
35
|
-
def write_entry(name, value, options =
|
36
|
-
@data[name] = value if
|
35
|
+
def write_entry(name, value, options = {})
|
36
|
+
@data[name] = value if options[:do_read_cache]
|
37
37
|
@cached << name
|
38
38
|
end
|
39
39
|
|
40
|
-
def delete_entry(name, options =
|
40
|
+
def delete_entry(name, options = {})
|
41
41
|
@expired << name
|
42
42
|
end
|
43
43
|
|
44
|
-
def delete_matched(matcher, options =
|
44
|
+
def delete_matched(matcher, options = {})
|
45
45
|
@expiration_patterns << matcher
|
46
46
|
end
|
47
47
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-rails-caching
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-04-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -98,7 +98,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
98
98
|
version: '0'
|
99
99
|
segments:
|
100
100
|
- 0
|
101
|
-
hash:
|
101
|
+
hash: 528426718858164885
|
102
102
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
103
103
|
none: false
|
104
104
|
requirements:
|
@@ -107,7 +107,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
107
107
|
version: '0'
|
108
108
|
segments:
|
109
109
|
- 0
|
110
|
-
hash:
|
110
|
+
hash: 528426718858164885
|
111
111
|
requirements: []
|
112
112
|
rubyforge_project:
|
113
113
|
rubygems_version: 1.8.25
|