permissioner 0.2.0.beta → 1.0.0.beta
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 +4 -4
- data/lib/permissioner/matchers/exactly_allow_attributes.rb +4 -4
- data/lib/permissioner/matchers/exactly_allow_controllers.rb +2 -2
- data/lib/permissioner/matchers/exactly_allow_resources.rb +2 -2
- data/lib/permissioner/matchers/exactly_expect_actions.rb +2 -2
- data/lib/permissioner/version.rb +1 -1
- data/permissioner.gemspec +4 -4
- data/spec/permissioner/configurer_spec.rb +9 -9
- data/spec/permissioner/controller_additions_spec.rb +17 -17
- data/spec/permissioner/matchers/exactly_allow_attributes_spec.rb +22 -22
- data/spec/permissioner/matchers/exactly_allow_controllers_spec.rb +11 -11
- data/spec/permissioner/matchers/exactly_allow_resources_spec.rb +10 -10
- data/spec/permissioner/matchers/exactly_expect_actions_spec.rb +17 -17
- data/spec/permissioner/matchers_spec.rb +22 -22
- data/spec/permissioner/service_additions_spec.rb +76 -76
- metadata +23 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 43616baad7f73fa5bc6d9fcf2503ad69cd745143
|
4
|
+
data.tar.gz: 7719b023c2d20c24ee4e9851c78f60d08c6dc612
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 39fc6a0d3c6b93f56bf0c2af626f4dac11571d7c3a42a2dfe82b80294b762a01150e288f1476b4eaacaa800545274dc5858a77271d55030e06d8fef57b93fcdb
|
7
|
+
data.tar.gz: b323e09b04b4d0b957ff908af916f855e0afaed3cc63b2733f3a6b18a382847e48d7d6b7b72169b51ecab7f3764cef03691a69b854475289340aa2191a973ded
|
@@ -15,7 +15,7 @@ module Permissioner
|
|
15
15
|
expected_attributes_exactly_match?
|
16
16
|
end
|
17
17
|
|
18
|
-
def
|
18
|
+
def failure_message
|
19
19
|
if @failing_attributes.empty?
|
20
20
|
"expected to find allowed attributes for resources\n" \
|
21
21
|
"#{all_expected_resources}, but found allowed attributes for resources\n"\
|
@@ -32,7 +32,7 @@ module Permissioner
|
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
|
-
def
|
35
|
+
def failure_message_when_negated
|
36
36
|
'given attributes are exactly allowed although this is not expected'
|
37
37
|
end
|
38
38
|
|
@@ -103,13 +103,13 @@ module Permissioner
|
|
103
103
|
# expected_attributs_exactly_macht? allowed_attributes_for_resource
|
104
104
|
#end
|
105
105
|
#
|
106
|
-
#def
|
106
|
+
#def failure_message
|
107
107
|
# "expected that for resource \"#{@resource}\" attributes\n"\
|
108
108
|
# "#{@expected_attributes} are exactly allowed, but found attributes\n"\
|
109
109
|
# "#{allowed_attributes_for_resource} allowed"
|
110
110
|
#end
|
111
111
|
#
|
112
|
-
#def
|
112
|
+
#def failure_message_when_negated
|
113
113
|
# "expected that for resource \"#{@resource}\" attributes\n"\
|
114
114
|
# "#{@expected_attributes} are exactly not allowed,\n"\
|
115
115
|
# "but those attributes are exactly allowed\n"
|
@@ -11,13 +11,13 @@ module Permissioner
|
|
11
11
|
controllers_exactly_match?(allowed_controllers)
|
12
12
|
end
|
13
13
|
|
14
|
-
def
|
14
|
+
def failure_message
|
15
15
|
"expected to exactly allow controllers \n" \
|
16
16
|
"#{@expected_controllers.sort}, but found controllers\n"\
|
17
17
|
"#{allowed_controllers.sort} allowed"
|
18
18
|
end
|
19
19
|
|
20
|
-
def
|
20
|
+
def failure_message_when_negated
|
21
21
|
"expected to exactly not allow controllers \n" \
|
22
22
|
"#{@expected_controllers.sort}, but these controllers are exactly allowed\n"\
|
23
23
|
end
|
@@ -11,13 +11,13 @@ module Permissioner
|
|
11
11
|
resources_exactly_match?
|
12
12
|
end
|
13
13
|
|
14
|
-
def
|
14
|
+
def failure_message
|
15
15
|
"expected to exactly allow resources \n" \
|
16
16
|
"#{@expected_resources.sort}, but found resources\n"\
|
17
17
|
"#{allowed_resources.sort} allowed"
|
18
18
|
end
|
19
19
|
|
20
|
-
def
|
20
|
+
def failure_message_when_negated
|
21
21
|
"expected to exactly not allow resources \n" \
|
22
22
|
"#{@expected_resources.sort}, but these resources are exactly allowed\n"\
|
23
23
|
end
|
@@ -16,7 +16,7 @@ module Permissioner
|
|
16
16
|
expected_actions_exactly_match?
|
17
17
|
end
|
18
18
|
|
19
|
-
def
|
19
|
+
def failure_message
|
20
20
|
if @failing_actions.empty?
|
21
21
|
"expected to find actions for controllers \n" \
|
22
22
|
"#{all_expected_controllers}, but found actions for controllers\n"\
|
@@ -33,7 +33,7 @@ module Permissioner
|
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
|
-
def
|
36
|
+
def failure_message_when_negated
|
37
37
|
'given actions are exactly match although this is not expected'
|
38
38
|
end
|
39
39
|
|
data/lib/permissioner/version.rb
CHANGED
data/permissioner.gemspec
CHANGED
@@ -18,8 +18,8 @@ Gem::Specification.new do |gem|
|
|
18
18
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
19
19
|
gem.require_paths = ["lib"]
|
20
20
|
|
21
|
-
gem.add_development_dependency "rspec", "
|
22
|
-
gem.add_development_dependency "activesupport", "
|
23
|
-
gem.add_development_dependency "actionpack", "
|
24
|
-
gem.add_development_dependency "guard-rspec", "
|
21
|
+
gem.add_development_dependency "rspec", ">=3.0.0"
|
22
|
+
gem.add_development_dependency "activesupport", ">=4.1.0"
|
23
|
+
gem.add_development_dependency "actionpack", ">=4.1.0"
|
24
|
+
gem.add_development_dependency "guard-rspec", ">=4.3.0"
|
25
25
|
end
|
@@ -13,24 +13,24 @@ describe Permissioner::Configurer do
|
|
13
13
|
let(:permission_configurer) { permission_configurer_class.new(permission_service, 'current_user') }
|
14
14
|
|
15
15
|
it 'should delegate call to allow_actions to permission_service' do
|
16
|
-
permission_service.
|
16
|
+
expect(permission_service).to receive(:allow_actions).with(:comments, :index)
|
17
17
|
permission_configurer.allow_actions(:comments, :index)
|
18
18
|
end
|
19
19
|
|
20
20
|
it 'should delegate call to allow_attributes to permission_service' do
|
21
|
-
permission_service.
|
21
|
+
expect(permission_service).to receive(:allow_attributes).with(:comment, [:user_id, :text])
|
22
22
|
permission_configurer.allow_attributes(:comment, [:user_id, :text])
|
23
23
|
end
|
24
24
|
|
25
25
|
it 'should delegate call to add_filter to permission_service' do
|
26
26
|
block = Proc.new {}
|
27
|
-
permission_service.
|
27
|
+
expect(permission_service).to receive(:add_filter).with(:comments, :create, &block)
|
28
28
|
permission_configurer.add_filter(:comments, :create, &block)
|
29
29
|
end
|
30
30
|
|
31
31
|
it 'should delegate call to clear_filter to permission_service' do
|
32
32
|
block = Proc.new {}
|
33
|
-
permission_service.
|
33
|
+
expect(permission_service).to receive(:clear_filters).with(no_args)
|
34
34
|
permission_configurer.clear_filters
|
35
35
|
end
|
36
36
|
end
|
@@ -39,11 +39,11 @@ describe Permissioner::Configurer do
|
|
39
39
|
subject(:permission_configurer){ permission_configurer_class.new(nil, nil) }
|
40
40
|
|
41
41
|
it 'should respond_to permission_service' do
|
42
|
-
|
42
|
+
is_expected.to respond_to(:permission_service)
|
43
43
|
end
|
44
44
|
|
45
45
|
it 'should respond_to current_user' do
|
46
|
-
|
46
|
+
is_expected.to respond_to(:current_user)
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
@@ -51,16 +51,16 @@ describe Permissioner::Configurer do
|
|
51
51
|
|
52
52
|
it 'should set permission_service' do
|
53
53
|
permission_configurer = permission_configurer_class.new('permission_service', nil)
|
54
|
-
permission_configurer.permission_service.
|
54
|
+
expect(permission_configurer.permission_service).to eq 'permission_service'
|
55
55
|
end
|
56
56
|
|
57
57
|
it 'should set current_user' do
|
58
58
|
permission_configurer = permission_configurer_class.new(nil, 'current_user')
|
59
|
-
permission_configurer.current_user.
|
59
|
+
expect(permission_configurer.current_user).to eq 'current_user'
|
60
60
|
end
|
61
61
|
|
62
62
|
it 'should call configure_permissions current_user' do
|
63
|
-
permission_configurer_class.
|
63
|
+
expect_any_instance_of(permission_configurer_class).to receive(:configure_permissions)
|
64
64
|
permission_configurer_class.new(nil, nil)
|
65
65
|
end
|
66
66
|
end
|
@@ -4,10 +4,10 @@ describe Permissioner::ControllerAdditions do
|
|
4
4
|
|
5
5
|
let(:controller) do
|
6
6
|
controller_class = Class.new
|
7
|
-
controller_class.
|
7
|
+
allow(controller_class).to receive(:helper_method)
|
8
8
|
controller_class.send(:include, Permissioner::ControllerAdditions)
|
9
9
|
controller = controller_class.new
|
10
|
-
controller.
|
10
|
+
allow(controller).to receive(:current_user)
|
11
11
|
controller
|
12
12
|
end
|
13
13
|
|
@@ -16,13 +16,13 @@ describe Permissioner::ControllerAdditions do
|
|
16
16
|
let(:clazz) { Class.new }
|
17
17
|
|
18
18
|
it 'should set view helpers' do
|
19
|
-
clazz.
|
19
|
+
expect(clazz).to receive(:helper_method).with(:allow_action?, :allow_attribute?, :permission_service)
|
20
20
|
clazz.send(:include, Permissioner::ControllerAdditions)
|
21
21
|
end
|
22
22
|
|
23
23
|
it 'should delegate helper methods to permission servie' do
|
24
|
-
clazz.
|
25
|
-
clazz.
|
24
|
+
allow(clazz).to receive(:helper_method)
|
25
|
+
expect(clazz).to receive(:delegate).with(:allow_action?, :allow_attribute?, to: :permission_service)
|
26
26
|
clazz.send(:include, Permissioner::ControllerAdditions)
|
27
27
|
end
|
28
28
|
end
|
@@ -32,23 +32,23 @@ describe Permissioner::ControllerAdditions do
|
|
32
32
|
let(:params) { {controller: 'comments', action: 'index'} }
|
33
33
|
|
34
34
|
before :each do
|
35
|
-
controller.
|
36
|
-
controller.
|
35
|
+
allow(controller).to receive(:current_resource).and_return('resource')
|
36
|
+
allow(controller).to receive(:params).and_return(params)
|
37
37
|
end
|
38
38
|
|
39
39
|
it 'should call permit_params! if action allwed and filters passed' do
|
40
|
-
controller.permission_service.
|
41
|
-
controller.permission_service.
|
40
|
+
expect(controller.permission_service).to receive(:allow_action?).and_return(true)
|
41
|
+
expect(controller.permission_service).to receive(:permit_params!).with(params)
|
42
42
|
controller.authorize
|
43
43
|
end
|
44
44
|
|
45
45
|
it 'should call allow_action? with correct parameters' do
|
46
|
-
controller.permission_service.
|
46
|
+
expect(controller.permission_service).to receive(:allow_action?).with('comments', 'index', resource: 'resource', params: params).and_return(true)
|
47
47
|
controller.authorize
|
48
48
|
end
|
49
49
|
|
50
50
|
it 'should raise Permissioner::NotAuthorized when action not allowed' do
|
51
|
-
controller.permission_service.
|
51
|
+
expect(controller.permission_service).to receive(:allow_action?).with('comments', 'index', resource: 'resource', params: params).and_return(false)
|
52
52
|
expect {
|
53
53
|
controller.authorize
|
54
54
|
}.to raise_error Permissioner::NotAuthorized
|
@@ -58,21 +58,21 @@ describe Permissioner::ControllerAdditions do
|
|
58
58
|
describe '#permission_service' do
|
59
59
|
|
60
60
|
it 'should return instance of PermissionService' do
|
61
|
-
controller.permission_service.class.
|
61
|
+
expect(controller.permission_service.class).to eq PermissionService
|
62
62
|
end
|
63
63
|
|
64
64
|
it 'should cache PermissionService instance' do
|
65
|
-
controller.permission_service.
|
65
|
+
expect(controller.permission_service).to be controller.permission_service
|
66
66
|
end
|
67
67
|
|
68
68
|
it 'should create PermissionService by calling PermissionService::new' do
|
69
|
-
PermissionService.
|
69
|
+
expect(PermissionService).to receive(:new)
|
70
70
|
controller.permission_service
|
71
71
|
end
|
72
72
|
|
73
73
|
it 'should pass current_user to PermissionService::initialize' do
|
74
|
-
controller.
|
75
|
-
PermissionService.
|
74
|
+
expect(controller).to receive(:current_user).and_return('current_user')
|
75
|
+
expect(PermissionService).to receive(:new).with('current_user')
|
76
76
|
controller.permission_service
|
77
77
|
end
|
78
78
|
end
|
@@ -80,7 +80,7 @@ describe Permissioner::ControllerAdditions do
|
|
80
80
|
describe '#current_resource' do
|
81
81
|
|
82
82
|
it 'should return nil as default' do
|
83
|
-
controller.current_resource.
|
83
|
+
expect(controller.current_resource).to be_nil
|
84
84
|
end
|
85
85
|
end
|
86
86
|
end
|
@@ -18,9 +18,9 @@ describe Permissioner::Matchers::ExactlyAllowAttributes do
|
|
18
18
|
|
19
19
|
it 'should ensure that all attributes are into an array' do
|
20
20
|
matcher = create_matcher [:resource, :attribute]
|
21
|
-
matcher.instance_variable_get(:@all_expected_attributes).
|
21
|
+
expect(matcher.instance_variable_get(:@all_expected_attributes)).to eq [[:resource, [:attribute]]]
|
22
22
|
matcher = create_matcher [:resource, [:attribute_1, :attribute_2]]
|
23
|
-
matcher.instance_variable_get(:@all_expected_attributes).
|
23
|
+
expect(matcher.instance_variable_get(:@all_expected_attributes)).to eq [[:resource, [:attribute_1, :attribute_2]]]
|
24
24
|
end
|
25
25
|
|
26
26
|
it 'should raise an exception if multiple actions not stated as array' do
|
@@ -40,7 +40,7 @@ describe Permissioner::Matchers::ExactlyAllowAttributes do
|
|
40
40
|
[:comment, [:user_id, :post_id, :content]],
|
41
41
|
[:post, [:user_id, :content]]
|
42
42
|
)
|
43
|
-
matcher.matches?(permission_service).
|
43
|
+
expect(matcher.matches?(permission_service)).to be_truthy
|
44
44
|
end
|
45
45
|
|
46
46
|
it 'should accept attributs being a hash' do
|
@@ -60,7 +60,7 @@ describe Permissioner::Matchers::ExactlyAllowAttributes do
|
|
60
60
|
]
|
61
61
|
]
|
62
62
|
)
|
63
|
-
matcher.matches?(permission_service).
|
63
|
+
expect(matcher.matches?(permission_service)).to be_truthy
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
@@ -72,7 +72,7 @@ describe Permissioner::Matchers::ExactlyAllowAttributes do
|
|
72
72
|
[:comment, [:user_id, :post_id, :content]],
|
73
73
|
[:account, [:user_id, :content]]
|
74
74
|
)
|
75
|
-
matcher.matches?(permission_service).
|
75
|
+
expect(matcher.matches?(permission_service)).to be_falsey
|
76
76
|
end
|
77
77
|
|
78
78
|
it 'should return false if at least one resource is allowed but no expected' do
|
@@ -80,7 +80,7 @@ describe Permissioner::Matchers::ExactlyAllowAttributes do
|
|
80
80
|
[:user, [:name, :email, :phone]],
|
81
81
|
[:comment, [:user_id, :post_id, :content]]
|
82
82
|
)
|
83
|
-
matcher.matches?(permission_service).
|
83
|
+
expect(matcher.matches?(permission_service)).to be_falsey
|
84
84
|
end
|
85
85
|
end
|
86
86
|
|
@@ -92,7 +92,7 @@ describe Permissioner::Matchers::ExactlyAllowAttributes do
|
|
92
92
|
[:comment, [:user_id, :post_id, :content]],
|
93
93
|
[:post, [:user_id, :content]]
|
94
94
|
)
|
95
|
-
matcher.matches?(permission_service).
|
95
|
+
expect(matcher.matches?(permission_service)).to be_falsey
|
96
96
|
end
|
97
97
|
|
98
98
|
it 'should return false if at least one attribute is allowed but not expected' do
|
@@ -101,27 +101,27 @@ describe Permissioner::Matchers::ExactlyAllowAttributes do
|
|
101
101
|
[:comment, [:user_id, :post_id, :content]],
|
102
102
|
[:post, [:user_id, :content]]
|
103
103
|
)
|
104
|
-
matcher.matches?(permission_service).
|
104
|
+
expect(matcher.matches?(permission_service)).to be_falsey
|
105
105
|
end
|
106
106
|
end
|
107
107
|
end
|
108
108
|
|
109
|
-
describe '#
|
109
|
+
describe '# failure_message_when_negated' do
|
110
110
|
|
111
111
|
it 'should be available' do
|
112
112
|
matcher = create_matcher
|
113
113
|
expected_messages = 'given attributes are exactly allowed although this is not expected'
|
114
|
-
matcher.
|
114
|
+
expect(matcher. failure_message_when_negated).to eq expected_messages
|
115
115
|
end
|
116
116
|
|
117
117
|
it 'should be available' do
|
118
118
|
matcher = create_matcher
|
119
119
|
matcher.matches?(PermissionService.new)
|
120
|
-
matcher.
|
120
|
+
expect(matcher. failure_message_when_negated).to be_kind_of(String)
|
121
121
|
end
|
122
122
|
end
|
123
123
|
|
124
|
-
describe '#
|
124
|
+
describe '#failure_message' do
|
125
125
|
|
126
126
|
context 'if resources did not match' do
|
127
127
|
|
@@ -136,7 +136,7 @@ describe Permissioner::Matchers::ExactlyAllowAttributes do
|
|
136
136
|
"[:comment, :post, :user]"
|
137
137
|
#call is necessary because matches sets @permission_service
|
138
138
|
matcher.matches?(permission_service)
|
139
|
-
matcher.
|
139
|
+
expect(matcher.failure_message).to eq expected_messages
|
140
140
|
end
|
141
141
|
|
142
142
|
it 'should work if no controller allowed' do
|
@@ -147,7 +147,7 @@ describe Permissioner::Matchers::ExactlyAllowAttributes do
|
|
147
147
|
)
|
148
148
|
#call is necessary because matches sets @permission_service
|
149
149
|
matcher.matches?(PermissionService.new)
|
150
|
-
matcher.
|
150
|
+
expect(matcher.failure_message).to be_kind_of(String)
|
151
151
|
end
|
152
152
|
end
|
153
153
|
|
@@ -170,7 +170,7 @@ describe Permissioner::Matchers::ExactlyAllowAttributes do
|
|
170
170
|
"[:user_id, :post_id, :content] are allowed\n"
|
171
171
|
#call is necessary because matches sets @permission_service
|
172
172
|
matcher.matches?(permission_service)
|
173
|
-
matcher.
|
173
|
+
expect(matcher.failure_message).to eq expected_messages
|
174
174
|
end
|
175
175
|
|
176
176
|
|
@@ -182,12 +182,12 @@ describe Permissioner::Matchers::ExactlyAllowAttributes do
|
|
182
182
|
)
|
183
183
|
#call is necessary because matches sets @permission_service
|
184
184
|
matcher.matches?(PermissionService.new)
|
185
|
-
matcher.
|
185
|
+
expect(matcher.failure_message).to be_kind_of(String)
|
186
186
|
end
|
187
187
|
end
|
188
188
|
end
|
189
189
|
|
190
|
-
#describe '#
|
190
|
+
#describe '#failure_message' do
|
191
191
|
#
|
192
192
|
# it 'should be available' do
|
193
193
|
# matcher = create_matcher :user, [:name, :email, :street]
|
@@ -196,17 +196,17 @@ describe Permissioner::Matchers::ExactlyAllowAttributes do
|
|
196
196
|
# "[:name, :email, :street] are exactly allowed, but found attributes\n"\
|
197
197
|
# "[:name, :email, :phone] allowed"
|
198
198
|
# matcher.matches?(permission_service)
|
199
|
-
# matcher.
|
199
|
+
# matcher.failure_message.should eq expected_messages
|
200
200
|
# end
|
201
201
|
#
|
202
202
|
# it 'should work if no controller allowed' do
|
203
203
|
# matcher = create_matcher :user, [:name, :email, :street]
|
204
204
|
# matcher.matches?(PermissionService.new)
|
205
|
-
# matcher.
|
205
|
+
# matcher.failure_message.should be_kind_of(String)
|
206
206
|
# end
|
207
207
|
#end
|
208
208
|
#
|
209
|
-
#describe '#
|
209
|
+
#describe '# failure_message_when_negated' do
|
210
210
|
#
|
211
211
|
# it 'should be available' do
|
212
212
|
# matcher = create_matcher :user, [:name, :email, :street]
|
@@ -215,13 +215,13 @@ describe Permissioner::Matchers::ExactlyAllowAttributes do
|
|
215
215
|
# "[:name, :email, :street] are exactly not allowed,\n"\
|
216
216
|
# "but those attributes are exactly allowed\n"
|
217
217
|
# matcher.matches?(permission_service)
|
218
|
-
# matcher.
|
218
|
+
# matcher. failure_message_when_negated.should eq expected_messages
|
219
219
|
# end
|
220
220
|
#
|
221
221
|
# it 'should work if no controller allowed' do
|
222
222
|
# matcher = create_matcher :user, [:name, :email, :street]
|
223
223
|
# matcher.matches?(PermissionService.new)
|
224
|
-
# matcher.
|
224
|
+
# matcher. failure_message_when_negated.should be_kind_of(String)
|
225
225
|
# end
|
226
226
|
#end
|
227
227
|
end
|
@@ -19,7 +19,7 @@ describe Permissioner::Matchers::ExactlyAllowControllers do
|
|
19
19
|
|
20
20
|
it 'should transform expected_controllers to strings' do
|
21
21
|
matcher = create_matcher(:comments, :users)
|
22
|
-
matcher.instance_variable_get(:@expected_controllers).
|
22
|
+
expect(matcher.instance_variable_get(:@expected_controllers)).to eq ['comments', 'users']
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
@@ -27,26 +27,26 @@ describe Permissioner::Matchers::ExactlyAllowControllers do
|
|
27
27
|
|
28
28
|
it 'should return true if exactly all expected controllers allowed' do
|
29
29
|
matcher = create_matcher(:comments, :users, :posts)
|
30
|
-
matcher.matches?(permission_service).
|
30
|
+
expect(matcher.matches?(permission_service)).to be_truthy
|
31
31
|
end
|
32
32
|
|
33
33
|
it 'should return false if at least one controller is not allowed' do
|
34
34
|
matcher = create_matcher(:comments, :users, :posts, :blogs)
|
35
|
-
matcher.matches?(permission_service).
|
35
|
+
expect(matcher.matches?(permission_service)).to be_falsey
|
36
36
|
end
|
37
37
|
|
38
38
|
it 'should return true if more controllers allowed than expected' do
|
39
39
|
matcher = create_matcher(:comments, :users)
|
40
|
-
matcher.matches?(permission_service).
|
40
|
+
expect(matcher.matches?(permission_service)).to be_falsey
|
41
41
|
end
|
42
42
|
|
43
43
|
it 'should work if no controller allowed' do
|
44
44
|
matcher = create_matcher(:comments, :users)
|
45
|
-
matcher.matches?(PermissionService.new).
|
45
|
+
expect(matcher.matches?(PermissionService.new)).to be_falsey
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
49
|
-
describe '#
|
49
|
+
describe '#failure_message' do
|
50
50
|
|
51
51
|
it 'should be available' do
|
52
52
|
matcher = create_matcher(:comments)
|
@@ -56,30 +56,30 @@ describe Permissioner::Matchers::ExactlyAllowControllers do
|
|
56
56
|
"[\"comments\", \"posts\", \"users\"] allowed"
|
57
57
|
#call is necessary because matches sets @permission_service
|
58
58
|
matcher.matches?(permission_service)
|
59
|
-
matcher.
|
59
|
+
expect(matcher.failure_message).to eq expected_messages
|
60
60
|
end
|
61
61
|
|
62
62
|
it 'should work if no controller allowed' do
|
63
63
|
matcher = create_matcher(:comments)
|
64
64
|
#call is necessary because matches sets @permission_service
|
65
65
|
matcher.matches?((PermissionService.new))
|
66
|
-
matcher.
|
66
|
+
expect(matcher.failure_message).to be_kind_of(String)
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
70
|
-
describe '#
|
70
|
+
describe '# failure_message_when_negated' do
|
71
71
|
|
72
72
|
it 'should be available' do
|
73
73
|
matcher = create_matcher(:users, :comments)
|
74
74
|
expected_messages =
|
75
75
|
"expected to exactly not allow controllers \n" \
|
76
76
|
"[\"comments\", \"users\"], but these controllers are exactly allowed\n"
|
77
|
-
matcher.
|
77
|
+
expect(matcher. failure_message_when_negated).to eq expected_messages
|
78
78
|
end
|
79
79
|
|
80
80
|
it 'should work if no controller allowed' do
|
81
81
|
matcher = create_matcher(:comments, :users)
|
82
|
-
matcher.
|
82
|
+
expect(matcher. failure_message_when_negated).to be_kind_of(String)
|
83
83
|
end
|
84
84
|
end
|
85
85
|
|