rspec-matchers-controller_filters 0.0.2 → 1.0.0
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6d4924b4b93e05fc59c0e0a60597759e267db63e
|
4
|
+
data.tar.gz: 7f1f530bcfe4bfbe3f8c4f7abf8f2fb05e68f569
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3fa04ed7362a952287691533e53d457b7029222eefbf37b8e890292d3d35563deb12ffb67ec9fd3b8b5fe7c8bc3489ec58a672e0409dc18ed4d9baac16a18a52
|
7
|
+
data.tar.gz: 04e7a558f2a2d31967829b4a99692cf76e6f90c433410e438bfb26ce15b3da5ada5a3fb691eb287a37ef064831e5ba4a9a5cb9ba5c50dd3864936cd702042146
|
data/README.md
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
# Rspec::Matchers::ControllerFilters
|
2
2
|
|
3
3
|
Use this gem to test execution of before/around/after filters of controller actions with RSpec.
|
4
|
+
|
5
|
+
Here's the general idea of the gem:
|
4
6
|
http://www.arubystory.com/2014/10/testing-execution-of-beforefilter-with.html
|
5
7
|
|
6
8
|
## Installation
|
@@ -24,9 +26,9 @@ Or install it yourself as:
|
|
24
26
|
In your controller specs you may use the new matchers:
|
25
27
|
|
26
28
|
```ruby
|
27
|
-
it { should
|
28
|
-
it { should_not
|
29
|
-
it { should
|
29
|
+
it { should execute_before_action :your_filter, :on => :your_action, :with => { :parameter_name => 'parameter_value'} }
|
30
|
+
it { should_not execute_around_action :your_filter, :on => :your_action, :with => { :parameter_name => 'parameter_value'} }
|
31
|
+
it { should execute_after_action :your_filter, :on => :your_action, :with => { :parameter_name => 'parameter_value'} }
|
30
32
|
```
|
31
33
|
|
32
34
|
The **with** parameter is optional.
|
@@ -39,9 +41,6 @@ The **with** parameter is optional.
|
|
39
41
|
4. Push to the branch (`git push origin my-new-feature`)
|
40
42
|
5. Create a new Pull Request
|
41
43
|
|
42
|
-
##
|
43
|
-
This is my first gem so please:
|
44
|
-
1. Use it at your own risk
|
45
|
-
2. Any feedback is welcome!
|
44
|
+
## License
|
46
45
|
|
47
|
-
|
46
|
+
This gem is open source under the [MIT License](https://opensource.org/licenses/MIT) terms.
|
@@ -99,6 +99,7 @@ module RSpec
|
|
99
99
|
RSpec::Matchers::ControllerFilters.resolve_failure_message :before, actual, expected, @routing_error, @unexpected_error, true
|
100
100
|
end
|
101
101
|
end
|
102
|
+
RSpec::Matchers.alias_matcher :execute_before_action, :execute_before_filter
|
102
103
|
|
103
104
|
RSpec::Matchers.define :execute_after_filter do |filter_name, options = {}|
|
104
105
|
match do |controller|
|
@@ -143,6 +144,7 @@ module RSpec
|
|
143
144
|
RSpec::Matchers::ControllerFilters.resolve_failure_message :after, actual, expected, @routing_error, @unexpected_error, true
|
144
145
|
end
|
145
146
|
end
|
147
|
+
RSpec::Matchers.alias_matcher :execute_after_action, :execute_after_filter
|
146
148
|
|
147
149
|
RSpec::Matchers.define :execute_around_filter do |filter_name, options = {}|
|
148
150
|
match do |controller|
|
@@ -169,11 +171,11 @@ module RSpec
|
|
169
171
|
|
170
172
|
send(options[:via] || :get, options[:on], options[:with])
|
171
173
|
@filter_executed && @action_executed
|
172
|
-
rescue ROUTING_ERROR_CLASS
|
173
|
-
@routing_error = true
|
174
|
-
negated
|
175
174
|
rescue RSpec::Matchers::ControllerFilters::FilterFailureError
|
176
175
|
false
|
176
|
+
rescue ROUTING_ERROR_CLASS => e
|
177
|
+
@routing_error = e.message
|
178
|
+
negated
|
177
179
|
rescue => e
|
178
180
|
@unexpected_error = e.message
|
179
181
|
negated
|
@@ -187,6 +189,7 @@ module RSpec
|
|
187
189
|
RSpec::Matchers::ControllerFilters.resolve_failure_message :around, actual, expected, @routing_error, @unexpected_error, true
|
188
190
|
end
|
189
191
|
end
|
192
|
+
RSpec::Matchers.alias_matcher :execute_around_action, :execute_around_filter
|
190
193
|
end
|
191
194
|
end
|
192
195
|
end
|
@@ -7,8 +7,8 @@ Gem::Specification.new do |spec|
|
|
7
7
|
spec.name = 'rspec-matchers-controller_filters'
|
8
8
|
spec.version = Rspec::Matchers::ControllerFilters::VERSION
|
9
9
|
spec.authors = ['Lazarus Lazaridis']
|
10
|
-
spec.summary = 'Test execution of before/around/after filters with RSpec'
|
11
|
-
spec.description = 'This gem defines custom
|
10
|
+
spec.summary = 'Test execution of before/around/after action filters with RSpec'
|
11
|
+
spec.description = 'This gem defines custom matchers that can be used to test execution of filters before, around or after controller actions.'
|
12
12
|
spec.homepage = 'https://github.com/iridakos/rspec-matchers-controller_filters'
|
13
13
|
spec.license = 'MIT'
|
14
14
|
|
data/spec/spec_helper.rb
CHANGED
@@ -4,8 +4,6 @@ Bundler.setup
|
|
4
4
|
require 'action_view'
|
5
5
|
require 'action_controller'
|
6
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'
|
7
|
+
#require 'rspec/rails/adapters'
|
8
|
+
#require 'rspec/rails/view_rendering'
|
11
9
|
require 'rspec/matchers/controller_filters'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-matchers-controller_filters
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lazarus Lazaridis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-03-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -58,7 +58,7 @@ dependencies:
|
|
58
58
|
- - ">="
|
59
59
|
- !ruby/object:Gem::Version
|
60
60
|
version: '3.1'
|
61
|
-
description: This gem defines custom
|
61
|
+
description: This gem defines custom matchers that can be used to test execution of
|
62
62
|
filters before, around or after controller actions.
|
63
63
|
email:
|
64
64
|
executables: []
|
@@ -95,10 +95,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
95
95
|
version: '0'
|
96
96
|
requirements: []
|
97
97
|
rubyforge_project:
|
98
|
-
rubygems_version: 2.
|
98
|
+
rubygems_version: 2.4.6
|
99
99
|
signing_key:
|
100
100
|
specification_version: 4
|
101
|
-
summary: Test execution of before/around/after filters with RSpec
|
101
|
+
summary: Test execution of before/around/after action filters with RSpec
|
102
102
|
test_files:
|
103
103
|
- spec/rspec/matchers/controller_filters/controller_filters_spec.rb
|
104
104
|
- spec/spec_helper.rb
|