rspec-rails-caching 0.2.2 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 0f710b5e9056169c689fb1f8cbaa4b63e71725e8
4
+ data.tar.gz: fbbaf90dc6d242f62712bed3dea05568e5794c4f
5
+ SHA512:
6
+ metadata.gz: f2956b05a07d828e74de424c93c2ea7a74c2bcf6929d05eee4a877068e5737fb90976fcb126d365f09e0e9131a8b2812c89714a8a1daeeea9be8e8a96048d3c8
7
+ data.tar.gz: c61d7a030a01458093d5f65691ce8feb1ac371df56df06b2878284101aef0f170fd21456c31ead993a7d908cd3dd0827612713bed291e012b25978aad6101c05
data/.gitignore CHANGED
@@ -1,17 +1,8 @@
1
+ .ruby-version
1
2
  *.gem
2
- *.rbc
3
- .bundle
4
- .config
5
- .yardoc
6
- Gemfile.lock
7
- InstalledFiles
8
- _yardoc
9
- coverage
10
- doc/
11
- lib/bundler/man
12
- pkg
13
- rdoc
14
- spec/reports
15
- test/tmp
16
- test/version_tmp
17
- tmp
3
+ /.bundle
4
+ /Gemfile.lock
5
+ /pkg
6
+ /doc
7
+ /tags
8
+ /tmp
data/Gemfile CHANGED
@@ -2,3 +2,8 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in rspec-rails-caching.gemspec
4
4
  gemspec
5
+
6
+ group :development do
7
+ gem 'actionpack-action_caching'
8
+ gem 'actionpack-page_caching'
9
+ end
data/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # RSpec Rails Caching
2
2
 
3
- Provides a cache store for recording and matchers for testing cache events in Rails controller tests.
3
+ Provides a cache store for recording and matchers for testing cache events in
4
+ Rails controller tests.
4
5
 
5
6
  ## Installation
6
7
 
@@ -18,10 +19,12 @@ Or install it yourself as:
18
19
 
19
20
  ## Usage
20
21
 
21
- Add `caching: true` as an option around a controller example group and use
22
- a proc or lambda around the action for matching:
22
+ Set `config.action_controller.perform_caching = true` in `config/environments/test.rb`
23
23
 
24
- describe WidgetsController, caching: true do
24
+ This gem captures the actual cache events for each request. In a controller
25
+ example group, use a proc or a lambda around the action for matching:
26
+
27
+ describe WidgetsController, type: :controller do
25
28
  it "should cache the show action" do
26
29
  ->{ get :show, id: 123 }.should cache_page('/widgets/123')
27
30
  end
@@ -25,6 +25,8 @@ module RSpecRailsCaching
25
25
  @data.clear
26
26
  @cached.clear
27
27
  @expired.clear
28
+ @cached_pages.clear
29
+ @expired_pages.clear
28
30
  @expiration_patterns.clear
29
31
  end
30
32
 
@@ -1,3 +1,3 @@
1
1
  module RSpecRailsCaching
2
- VERSION = "0.2.2"
2
+ VERSION = "0.3.0"
3
3
  end
@@ -0,0 +1,42 @@
1
+ require_relative '../spec_helper'
2
+ require_relative '../resources/controllers/page_cache_spec_controller'
3
+
4
+ describe PageCacheSpecController, :type => :controller do
5
+ describe "response.should cache_page" do
6
+
7
+ it "matches an action for a cached page" do
8
+ expect {
9
+ expect { get "action_with_page_caching" }
10
+ .to cache_page '/action_with_page_caching'
11
+ }.to_not raise_error
12
+ end
13
+
14
+ it "does not match an action for an uncached page" do
15
+ expect {
16
+ expect { get "action_without_page_caching" }
17
+ .to cache_page '/action_without_page_caching'
18
+ }.to raise_error(RSpec::Expectations::ExpectationNotMetError)
19
+ end
20
+
21
+ end
22
+
23
+ describe "response.should expire_page" do
24
+
25
+ it "matches an action for an expired page" do
26
+ expect {
27
+ get "action_with_page_caching"
28
+ expect { get "action_with_page_expiry" }
29
+ .to expire_page '/action_with_page_caching'
30
+ }.to_not raise_error
31
+ end
32
+
33
+ it "does not match an action without expiry" do
34
+ expect {
35
+ expect { get "action_with_page_caching" }
36
+ .to expire_page '/action_with_page_caching'
37
+ }.to raise_error(RSpec::Expectations::ExpectationNotMetError)
38
+ end
39
+
40
+ end
41
+
42
+ end
@@ -0,0 +1,32 @@
1
+ class PageCacheSpecController < ActionController::Base
2
+ include Rails.application.routes.url_helpers
3
+
4
+ caches_page :action_with_page_caching
5
+
6
+ def action_without_page_caching
7
+ render :text => ""
8
+ end
9
+
10
+ def action_with_page_caching
11
+ render :text => ""
12
+ end
13
+
14
+ def action_with_page_expiry
15
+ expire_page :action => 'action_with_page_caching'
16
+ render :text => ""
17
+ end
18
+ end
19
+
20
+ RSpec::Rails::Application.routes.draw do
21
+ get "action_without_page_caching",
22
+ :controller => "page_cache_spec",
23
+ :action => "action_without_page_caching"
24
+
25
+ get "action_with_page_caching",
26
+ :controller => "page_cache_spec",
27
+ :action => "action_with_page_caching"
28
+
29
+ get "action_with_page_expiry",
30
+ :controller => "page_cache_spec",
31
+ :action => "action_with_page_expiry"
32
+ end
@@ -0,0 +1,27 @@
1
+ require 'rails'
2
+ require 'action_controller/railtie'
3
+ unless Rails::VERSION::MAJOR < 4
4
+ require 'action_controller/action_caching'
5
+ require 'action_controller/page_caching'
6
+ end
7
+ require 'rspec/rails'
8
+ require 'rspec-rails-caching'
9
+
10
+ module RSpec::Rails
11
+ class Application < ::Rails::Application
12
+ config.secret_key_base = 'test'
13
+ config.action_controller.page_cache_directory =
14
+ File.dirname(__FILE__)
15
+ end
16
+ end
17
+
18
+ RSpec.configure do |config|
19
+ config.before(:each) do
20
+ @real_world = RSpec.world
21
+ RSpec.instance_variable_set(:@world, RSpec::Core::World.new)
22
+ end
23
+ config.after(:each) do
24
+ RSpec.instance_variable_set(:@world, @real_world)
25
+ end
26
+ config.order = :random
27
+ end
metadata CHANGED
@@ -1,62 +1,55 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-rails-caching
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
5
- prerelease:
4
+ version: 0.3.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Andrew Vit
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-05-15 00:00:00.000000000 Z
11
+ date: 2014-03-10 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rails
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: 3.0.0
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - '>='
28
25
  - !ruby/object:Gem::Version
29
26
  version: 3.0.0
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: rspec
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - '>='
36
32
  - !ruby/object:Gem::Version
37
33
  version: 2.8.0
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - '>='
44
39
  - !ruby/object:Gem::Version
45
40
  version: 2.8.0
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: rspec-rails
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - '>='
52
46
  - !ruby/object:Gem::Version
53
47
  version: 2.10.0
54
48
  type: :runtime
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - '>='
60
53
  - !ruby/object:Gem::Version
61
54
  version: 2.10.0
62
55
  description: RSpec helper for testing page and action caching in Rails
@@ -84,34 +77,34 @@ files:
84
77
  - lib/rspec-rails-caching/test_store.rb
85
78
  - lib/rspec-rails-caching/version.rb
86
79
  - rspec-rails-caching.gemspec
80
+ - spec/controllers/page_caching_spec.rb
81
+ - spec/resources/controllers/page_cache_spec_controller.rb
82
+ - spec/spec_helper.rb
87
83
  homepage: https://github.com/avit/rspec-rails-caching
88
84
  licenses: []
85
+ metadata: {}
89
86
  post_install_message:
90
87
  rdoc_options: []
91
88
  require_paths:
92
89
  - lib
93
90
  required_ruby_version: !ruby/object:Gem::Requirement
94
- none: false
95
91
  requirements:
96
- - - ! '>='
92
+ - - '>='
97
93
  - !ruby/object:Gem::Version
98
94
  version: '0'
99
- segments:
100
- - 0
101
- hash: 1642965200831011814
102
95
  required_rubygems_version: !ruby/object:Gem::Requirement
103
- none: false
104
96
  requirements:
105
- - - ! '>='
97
+ - - '>='
106
98
  - !ruby/object:Gem::Version
107
99
  version: '0'
108
- segments:
109
- - 0
110
- hash: 1642965200831011814
111
100
  requirements: []
112
101
  rubyforge_project:
113
- rubygems_version: 1.8.25
102
+ rubygems_version: 2.2.1
114
103
  signing_key:
115
- specification_version: 3
104
+ specification_version: 4
116
105
  summary: RSpec Rails Caching
117
- test_files: []
106
+ test_files:
107
+ - spec/controllers/page_caching_spec.rb
108
+ - spec/resources/controllers/page_cache_spec_controller.rb
109
+ - spec/spec_helper.rb
110
+ has_rdoc: