rspec-matchers-controller_filters 0.0.2
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 +7 -0
- data/.gitignore +14 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +47 -0
- data/Rakefile +10 -0
- data/lib/rspec/matchers/controller_filters.rb +192 -0
- data/lib/rspec/matchers/controller_filters/version.rb +7 -0
- data/rspec-matchers-controller_filters.gemspec +24 -0
- data/spec/rspec/matchers/controller_filters/controller_filters_spec.rb +131 -0
- data/spec/spec_helper.rb +11 -0
- metadata +104 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 9b46a7e5fce634af5c3ed5117755a502fa9a0593
|
4
|
+
data.tar.gz: 6fc3d2728a1b707fd7781496acf9335930b7dda1
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d29ed4e300b76461d678fe85777debc91674f2429e82a40eb0e09732776e4d2db7623638fdfe530356f0b7ea3da1d551b3752d1ee02c28df6104f9b3b3d6a700
|
7
|
+
data.tar.gz: f87f201db6ac2760be2713afdfb2e52bf52eeb273ff14de7c8945b666a7bfdd12e27a0a296353a3cfd195a287ac0473d221b09805941297e40d3c5e10b60b0a1
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 Lazarus Lazaridis
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
# Rspec::Matchers::ControllerFilters
|
2
|
+
|
3
|
+
Use this gem to test execution of before/around/after filters of controller actions with RSpec.
|
4
|
+
http://www.arubystory.com/2014/10/testing-execution-of-beforefilter-with.html
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
Add this line to your application's Gemfile:
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
gem 'rspec-matchers-controller_filters'
|
12
|
+
```
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
|
16
|
+
$ bundle
|
17
|
+
|
18
|
+
Or install it yourself as:
|
19
|
+
|
20
|
+
$ gem install rspec-matchers-controller_filters
|
21
|
+
|
22
|
+
## Usage
|
23
|
+
|
24
|
+
In your controller specs you may use the new matchers:
|
25
|
+
|
26
|
+
```ruby
|
27
|
+
it { should execute_before_filter :your_filter, :on => :your_action, :with => { :parameter_name => 'parameter_value'} }
|
28
|
+
it { should_not execute_around_filter :your_filter, :on => :your_action, :with => { :parameter_name => 'parameter_value'} }
|
29
|
+
it { should execute_after_filter :your_filter, :on => :your_action, :with => { :parameter_name => 'parameter_value'} }
|
30
|
+
```
|
31
|
+
|
32
|
+
The **with** parameter is optional.
|
33
|
+
|
34
|
+
## Contributing
|
35
|
+
|
36
|
+
1. Fork it ( https://github.com/iridakos/rspec-matchers-controller_filters/fork )
|
37
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
38
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
39
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
40
|
+
5. Create a new Pull Request
|
41
|
+
|
42
|
+
## Important note
|
43
|
+
This is my first gem so please:
|
44
|
+
1. Use it at your own risk
|
45
|
+
2. Any feedback is welcome!
|
46
|
+
|
47
|
+
##### [**Lazarus Lazaridis**](http://twitter.com/arubystory)
|
data/Rakefile
ADDED
@@ -0,0 +1,192 @@
|
|
1
|
+
require 'rspec/matchers/controller_filters/version'
|
2
|
+
require 'rspec/matchers'
|
3
|
+
|
4
|
+
module RSpec
|
5
|
+
module Matchers
|
6
|
+
module ControllerFilters
|
7
|
+
# Error signaling that a matcher fails.
|
8
|
+
class FilterFailureError < StandardError;
|
9
|
+
end
|
10
|
+
|
11
|
+
# Support for Rails 3, 4
|
12
|
+
ROUTING_ERROR_CLASS = defined?(ActionController::UrlGenerationError) ? ActionController::UrlGenerationError : (defined?(ActionController::RoutingError) ? ActionController::RoutingError : StandardError )
|
13
|
+
|
14
|
+
class << self
|
15
|
+
# Resolves the error message to show for a failing test.
|
16
|
+
#
|
17
|
+
# If neither a routing nor an unexpected error has occurred, the message to be displayed describes the failed expectation.
|
18
|
+
def resolve_failure_message(scope, actual, expectations, routing_error, unexpected_error, negated)
|
19
|
+
return unexpected_failure_message_for scope, actual, expectations, unexpected_error if unexpected_error.present?
|
20
|
+
return routing_failure_message_for scope, actual, expectations, routing_error if routing_error.present?
|
21
|
+
failure_message_for scope, actual, expectations, negated
|
22
|
+
end
|
23
|
+
|
24
|
+
protected
|
25
|
+
|
26
|
+
def failure_message_for(scope, actual, expectations, negated)
|
27
|
+
filter = expectations[0]
|
28
|
+
options = expectations[1]
|
29
|
+
action = options[:on]
|
30
|
+
via = options[:via]
|
31
|
+
params = options[:with]
|
32
|
+
|
33
|
+
"Expected #{actual.class} #{negated ? 'not ' : ''}to execute filter '#{filter}' #{scope.to_s} action '#{action}' (request made via #{via} with params '#{params}') but it did#{negated ? '' : 'n\'t'}."
|
34
|
+
end
|
35
|
+
|
36
|
+
def routing_failure_message_for(scope, actual, expectations, routing_error)
|
37
|
+
filter = expectations[0]
|
38
|
+
options = expectations[1]
|
39
|
+
action = options[:on]
|
40
|
+
via = options[:via]
|
41
|
+
params = options[:with]
|
42
|
+
|
43
|
+
message = "Routing error while trying to check if #{actual.class} executes '#{filter}' #{scope.to_s} action '#{action}' (request made via #{via} with params '#{params}').\n"
|
44
|
+
message << "Check your params (ex you might need to include an id).\n"
|
45
|
+
message << "Routing error description: #{routing_error}"
|
46
|
+
end
|
47
|
+
|
48
|
+
def unexpected_failure_message_for(scope, actual, expectations, unexpected_error)
|
49
|
+
filter = expectations[0]
|
50
|
+
options = expectations[1]
|
51
|
+
action = options[:on]
|
52
|
+
via = options[:via]
|
53
|
+
params = options[:with]
|
54
|
+
|
55
|
+
message = "Unexpected error while trying to check if #{actual.class} executes '#{filter}' #{scope.to_s} action '#{action}' (request made via #{via} with params '#{params}').\n"
|
56
|
+
message << "Error description: #{unexpected_error}"
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
RSpec::Matchers.define :execute_before_filter do |filter_name, options = {}|
|
61
|
+
match do |controller|
|
62
|
+
execute_match(filter_name, options, false)
|
63
|
+
end
|
64
|
+
|
65
|
+
match_when_negated do |controller|
|
66
|
+
!execute_match(filter_name, options, true)
|
67
|
+
end
|
68
|
+
|
69
|
+
def execute_match(filter_name, options, negated)
|
70
|
+
allow(controller).to receive(filter_name).and_wrap_original { |&block|
|
71
|
+
@filter_executed = block.nil?
|
72
|
+
}
|
73
|
+
|
74
|
+
allow(controller).to receive(options[:on]) {
|
75
|
+
raise RSpec::Matchers::ControllerFilters::FilterFailureError if !@filter_executed || @action_executed
|
76
|
+
@action_executed = true
|
77
|
+
controller.render :text => 'success'
|
78
|
+
}
|
79
|
+
|
80
|
+
begin
|
81
|
+
send(options[:via] || :get, options[:on], options[:with])
|
82
|
+
@filter_executed
|
83
|
+
rescue RSpec::Matchers::ControllerFilters::FilterFailureError
|
84
|
+
false
|
85
|
+
rescue ROUTING_ERROR_CLASS => e
|
86
|
+
@routing_error = e.message
|
87
|
+
negated
|
88
|
+
rescue => e
|
89
|
+
@unexpected_error = e.message
|
90
|
+
negated
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
failure_message do |actual|
|
95
|
+
RSpec::Matchers::ControllerFilters.resolve_failure_message :before, actual, expected, @routing_error, @unexpected_error, false
|
96
|
+
end
|
97
|
+
|
98
|
+
failure_message_when_negated do |actual|
|
99
|
+
RSpec::Matchers::ControllerFilters.resolve_failure_message :before, actual, expected, @routing_error, @unexpected_error, true
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
RSpec::Matchers.define :execute_after_filter do |filter_name, options = {}|
|
104
|
+
match do |controller|
|
105
|
+
execute_match(filter_name, options, false)
|
106
|
+
end
|
107
|
+
|
108
|
+
match_when_negated do |controller|
|
109
|
+
!execute_match(filter_name, options, true)
|
110
|
+
end
|
111
|
+
|
112
|
+
def execute_match(filter_name, options, negated)
|
113
|
+
allow(controller).to receive(filter_name) {
|
114
|
+
raise RSpec::Matchers::ControllerFilters::FilterFailureError unless @action_executed
|
115
|
+
@filter_executed = true
|
116
|
+
}
|
117
|
+
allow(controller).to receive(options[:on]) {
|
118
|
+
@action_executed = true
|
119
|
+
controller.render(:nothing => true)
|
120
|
+
}
|
121
|
+
|
122
|
+
result = begin
|
123
|
+
send(options[:via] || :get, options[:on], options[:with])
|
124
|
+
@action_executed && @filter_executed
|
125
|
+
rescue RSpec::Matchers::ControllerFilters::FilterFailureError
|
126
|
+
false
|
127
|
+
rescue ROUTING_ERROR_CLASS => e
|
128
|
+
@routing_error = e.message
|
129
|
+
negated
|
130
|
+
rescue => e
|
131
|
+
@unexpected_error = e.message
|
132
|
+
negated
|
133
|
+
end
|
134
|
+
|
135
|
+
result
|
136
|
+
end
|
137
|
+
|
138
|
+
failure_message do |actual|
|
139
|
+
RSpec::Matchers::ControllerFilters.resolve_failure_message :after, actual, expected, @routing_error, @unexpected_error, false
|
140
|
+
end
|
141
|
+
|
142
|
+
failure_message_when_negated do |actual|
|
143
|
+
RSpec::Matchers::ControllerFilters.resolve_failure_message :after, actual, expected, @routing_error, @unexpected_error, true
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
RSpec::Matchers.define :execute_around_filter do |filter_name, options = {}|
|
148
|
+
match do |controller|
|
149
|
+
execute_match(filter_name, options, false)
|
150
|
+
end
|
151
|
+
|
152
|
+
match_when_negated do |controller|
|
153
|
+
!execute_match(filter_name, options, true)
|
154
|
+
end
|
155
|
+
|
156
|
+
def execute_match(filter_name, options, negated)
|
157
|
+
allow(controller).to receive(options[:on]) {
|
158
|
+
if !@filter_executed || @action_executed
|
159
|
+
raise RSpec::Matchers::ControllerFilters::FilterFailureError
|
160
|
+
else
|
161
|
+
@action_executed = true
|
162
|
+
end
|
163
|
+
}
|
164
|
+
|
165
|
+
allow(controller).to receive(filter_name) {
|
166
|
+
@filter_executed = true
|
167
|
+
controller.send(options[:on])
|
168
|
+
}
|
169
|
+
|
170
|
+
send(options[:via] || :get, options[:on], options[:with])
|
171
|
+
@filter_executed && @action_executed
|
172
|
+
rescue ROUTING_ERROR_CLASS
|
173
|
+
@routing_error = true
|
174
|
+
negated
|
175
|
+
rescue RSpec::Matchers::ControllerFilters::FilterFailureError
|
176
|
+
false
|
177
|
+
rescue => e
|
178
|
+
@unexpected_error = e.message
|
179
|
+
negated
|
180
|
+
end
|
181
|
+
|
182
|
+
failure_message do |actual|
|
183
|
+
RSpec::Matchers::ControllerFilters.resolve_failure_message :around, actual, expected, @routing_error, @unexpected_error, false
|
184
|
+
end
|
185
|
+
|
186
|
+
failure_message_when_negated do |actual|
|
187
|
+
RSpec::Matchers::ControllerFilters.resolve_failure_message :around, actual, expected, @routing_error, @unexpected_error, true
|
188
|
+
end
|
189
|
+
end
|
190
|
+
end
|
191
|
+
end
|
192
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'rspec/matchers/controller_filters/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'rspec-matchers-controller_filters'
|
8
|
+
spec.version = Rspec::Matchers::ControllerFilters::VERSION
|
9
|
+
spec.authors = ['Lazarus Lazaridis']
|
10
|
+
spec.summary = 'Test execution of before/around/after filters with RSpec'
|
11
|
+
spec.description = 'This gem defines custom filters that can be used to test execution of filters before, around or after controller actions.'
|
12
|
+
spec.homepage = 'https://github.com/iridakos/rspec-matchers-controller_filters'
|
13
|
+
spec.license = 'MIT'
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0")
|
16
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
+
spec.require_paths = ['lib']
|
19
|
+
|
20
|
+
spec.add_development_dependency 'bundler', '~> 1.7'
|
21
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
22
|
+
|
23
|
+
spec.add_runtime_dependency 'rspec-rails', '~> 3', '>= 3.1'
|
24
|
+
end
|
@@ -0,0 +1,131 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
require 'rails/all'
|
4
|
+
require 'rspec/rails'
|
5
|
+
require 'action_controller/railtie'
|
6
|
+
|
7
|
+
module Test
|
8
|
+
class TestApplication < ::Rails::Application; end
|
9
|
+
|
10
|
+
TestApplication.config.secret_key_base = 'test'
|
11
|
+
|
12
|
+
class TestsController < ActionController::Base
|
13
|
+
include ::Rails.application.routes.url_helpers
|
14
|
+
|
15
|
+
before_filter :a_before_filter, :only => [:before_filter_collection_action,
|
16
|
+
:before_and_around_filter_collection_action,
|
17
|
+
:before_and_after_filter_collection_action,
|
18
|
+
:before_filter_member_action,
|
19
|
+
:before_and_around_filter_member_action,
|
20
|
+
:before_and_after_filter_member_action]
|
21
|
+
|
22
|
+
around_filter :an_around_filter, :only => [:before_and_around_filter_collection_action,
|
23
|
+
:around_filter_collection_action,
|
24
|
+
:around_and_after_filter_collection_action,
|
25
|
+
:before_and_around_filter_member_action,
|
26
|
+
:around_filter_member_action,
|
27
|
+
:around_and_after_filter_member_action]
|
28
|
+
|
29
|
+
after_filter :an_after_filter, :only => [:before_and_after_filter_collection_action,
|
30
|
+
:around_and_after_filter_collection_action,
|
31
|
+
:after_filter_collection_action,
|
32
|
+
:before_and_after_filter_member_action,
|
33
|
+
:around_and_after_filter_member_action,
|
34
|
+
:after_filter_member_action]
|
35
|
+
|
36
|
+
def before_filter_collection_action; end
|
37
|
+
def around_filter_collection_action; end
|
38
|
+
def after_filter_collection_action; end
|
39
|
+
def before_and_around_filter_collection_action; end
|
40
|
+
def before_and_after_filter_collection_action; end
|
41
|
+
def around_and_after_filter_collection_action; end
|
42
|
+
def before_filter_member_action; end
|
43
|
+
def around_filter_member_action; end
|
44
|
+
def after_filter_member_action; end
|
45
|
+
def before_and_around_filter_member_action; end
|
46
|
+
def before_and_after_filter_member_action; end
|
47
|
+
def around_and_after_filter_member_action; end
|
48
|
+
|
49
|
+
protected
|
50
|
+
|
51
|
+
def a_before_filter; end
|
52
|
+
def an_around_filter; yield; end
|
53
|
+
def an_after_filter; end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
RSpec.describe Test::TestsController, :type => :controller do
|
58
|
+
before do
|
59
|
+
routes.draw {
|
60
|
+
namespace :test do
|
61
|
+
resources :tests, :only => [] do
|
62
|
+
collection do
|
63
|
+
get :before_filter_collection_action
|
64
|
+
get :around_filter_collection_action
|
65
|
+
get :after_filter_collection_action
|
66
|
+
get :before_and_around_filter_collection_action
|
67
|
+
get :before_and_after_filter_collection_action
|
68
|
+
get :around_and_after_filter_collection_action
|
69
|
+
end
|
70
|
+
|
71
|
+
member do
|
72
|
+
get :before_filter_member_action
|
73
|
+
get :around_filter_member_action
|
74
|
+
get :after_filter_member_action
|
75
|
+
get :before_and_around_filter_member_action
|
76
|
+
get :before_and_after_filter_member_action
|
77
|
+
get :around_and_after_filter_member_action
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
}
|
82
|
+
end
|
83
|
+
|
84
|
+
describe ':execute_before_filter' do
|
85
|
+
it { should execute_before_filter :a_before_filter, :on => :before_filter_collection_action, :via => :get }
|
86
|
+
it { should execute_before_filter :a_before_filter, :on => :before_and_around_filter_collection_action, :via => :get }
|
87
|
+
it { should execute_before_filter :a_before_filter, :on => :before_and_after_filter_collection_action, :via => :get }
|
88
|
+
it { should execute_before_filter :a_before_filter, :on => :before_filter_member_action, :via => :get, :with => { :id => 1 } }
|
89
|
+
it { should execute_before_filter :a_before_filter, :on => :before_and_around_filter_member_action, :via => :get, :with => { :id => 1 } }
|
90
|
+
it { should execute_before_filter :a_before_filter, :on => :before_and_after_filter_member_action, :via => :get, :with => { :id => 1 } }
|
91
|
+
|
92
|
+
it { should_not execute_before_filter :a_before_filter, :on => :around_filter_collection_action, :via => :get }
|
93
|
+
it { should_not execute_before_filter :a_before_filter, :on => :after_filter_collection_action, :via => :get }
|
94
|
+
it { should_not execute_before_filter :a_before_filter, :on => :around_and_after_filter_collection_action, :via => :get }
|
95
|
+
it { should_not execute_before_filter :a_before_filter, :on => :around_filter_member_action, :via => :get, :with => { :id => 1 } }
|
96
|
+
it { should_not execute_before_filter :a_before_filter, :on => :after_filter_member_action, :via => :get, :with => { :id => 1 } }
|
97
|
+
it { should_not execute_before_filter :a_before_filter, :on => :around_and_after_filter_member_action, :via => :get, :with => { :id => 1 } }
|
98
|
+
end
|
99
|
+
|
100
|
+
describe ':execute_around_filter' do
|
101
|
+
it { should execute_around_filter :an_around_filter, :on => :before_and_around_filter_collection_action, :via => :get }
|
102
|
+
it { should execute_around_filter :an_around_filter, :on => :before_and_around_filter_member_action, :via => :get, :with => { :id => 1 } }
|
103
|
+
it { should execute_around_filter :an_around_filter, :on => :around_filter_collection_action, :via => :get }
|
104
|
+
it { should execute_around_filter :an_around_filter, :on => :around_filter_member_action, :via => :get, :with => { :id => 1 } }
|
105
|
+
it { should execute_around_filter :an_around_filter, :on => :around_and_after_filter_collection_action, :via => :get }
|
106
|
+
it { should execute_around_filter :an_around_filter, :on => :around_and_after_filter_member_action, :via => :get, :with => { :id => 1 } }
|
107
|
+
|
108
|
+
it { should_not execute_around_filter :an_around_filter, :on => :before_and_after_filter_collection_action, :via => :get }
|
109
|
+
it { should_not execute_around_filter :an_around_filter, :on => :before_and_after_filter_member_action, :via => :get, :with => { :id => 1 } }
|
110
|
+
it { should_not execute_around_filter :an_around_filter, :on => :after_filter_collection_action, :via => :get }
|
111
|
+
it { should_not execute_around_filter :an_around_filter, :on => :after_filter_member_action, :via => :get, :with => { :id => 1 } }
|
112
|
+
it { should_not execute_around_filter :an_around_filter, :on => :before_filter_collection_action, :via => :get }
|
113
|
+
it { should_not execute_around_filter :an_around_filter, :on => :before_filter_member_action, :via => :get, :with => { :id => 1 } }
|
114
|
+
end
|
115
|
+
|
116
|
+
describe ':execute_after_filter' do
|
117
|
+
it { should execute_after_filter :an_after_filter, :on => :before_and_after_filter_collection_action, :via => :get }
|
118
|
+
it { should execute_after_filter :an_after_filter, :on => :before_and_after_filter_member_action, :via => :get, :with => { :id => 1 } }
|
119
|
+
it { should execute_after_filter :an_after_filter, :on => :after_filter_collection_action, :via => :get }
|
120
|
+
it { should execute_after_filter :an_after_filter, :on => :around_and_after_filter_collection_action, :via => :get }
|
121
|
+
it { should execute_after_filter :an_after_filter, :on => :after_filter_member_action, :via => :get, :with => { :id => 1 } }
|
122
|
+
it { should execute_after_filter :an_after_filter, :on => :around_and_after_filter_member_action, :via => :get, :with => { :id => 1 } }
|
123
|
+
|
124
|
+
it { should_not execute_after_filter :an_after_filter, :on => :before_filter_collection_action, :via => :get }
|
125
|
+
it { should_not execute_after_filter :an_after_filter, :on => :before_and_around_filter_collection_action, :via => :get }
|
126
|
+
it { should_not execute_after_filter :an_after_filter, :on => :before_filter_member_action, :via => :get, :with => { :id => 1 } }
|
127
|
+
it { should_not execute_after_filter :an_after_filter, :on => :before_and_around_filter_member_action, :via => :get, :with => { :id => 1 } }
|
128
|
+
it { should_not execute_after_filter :an_after_filter, :on => :around_filter_collection_action, :via => :get }
|
129
|
+
it { should_not execute_after_filter :an_after_filter, :on => :around_filter_member_action, :via => :get, :with => { :id => 1 } }
|
130
|
+
end
|
131
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'bundler/setup'
|
2
|
+
Bundler.setup
|
3
|
+
|
4
|
+
require 'action_view'
|
5
|
+
require 'action_controller'
|
6
|
+
require 'rails'
|
7
|
+
require 'rspec/rails/adapters'
|
8
|
+
require 'rspec/rails/view_rendering'
|
9
|
+
require 'rspec/rails/example/rails_example_group'
|
10
|
+
require 'rspec/rails/example/controller_example_group'
|
11
|
+
require 'rspec/matchers/controller_filters'
|
metadata
ADDED
@@ -0,0 +1,104 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rspec-matchers-controller_filters
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Lazarus Lazaridis
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-03-08 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.7'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec-rails
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3'
|
48
|
+
- - ">="
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: '3.1'
|
51
|
+
type: :runtime
|
52
|
+
prerelease: false
|
53
|
+
version_requirements: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - "~>"
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: '3'
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '3.1'
|
61
|
+
description: This gem defines custom filters that can be used to test execution of
|
62
|
+
filters before, around or after controller actions.
|
63
|
+
email:
|
64
|
+
executables: []
|
65
|
+
extensions: []
|
66
|
+
extra_rdoc_files: []
|
67
|
+
files:
|
68
|
+
- ".gitignore"
|
69
|
+
- Gemfile
|
70
|
+
- LICENSE.txt
|
71
|
+
- README.md
|
72
|
+
- Rakefile
|
73
|
+
- lib/rspec/matchers/controller_filters.rb
|
74
|
+
- lib/rspec/matchers/controller_filters/version.rb
|
75
|
+
- rspec-matchers-controller_filters.gemspec
|
76
|
+
- spec/rspec/matchers/controller_filters/controller_filters_spec.rb
|
77
|
+
- spec/spec_helper.rb
|
78
|
+
homepage: https://github.com/iridakos/rspec-matchers-controller_filters
|
79
|
+
licenses:
|
80
|
+
- MIT
|
81
|
+
metadata: {}
|
82
|
+
post_install_message:
|
83
|
+
rdoc_options: []
|
84
|
+
require_paths:
|
85
|
+
- lib
|
86
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '0'
|
91
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
96
|
+
requirements: []
|
97
|
+
rubyforge_project:
|
98
|
+
rubygems_version: 2.2.2
|
99
|
+
signing_key:
|
100
|
+
specification_version: 4
|
101
|
+
summary: Test execution of before/around/after filters with RSpec
|
102
|
+
test_files:
|
103
|
+
- spec/rspec/matchers/controller_filters/controller_filters_spec.rb
|
104
|
+
- spec/spec_helper.rb
|