pundit-matchers 1.7.0 → 1.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/pundit/matchers.rb +30 -0
  3. metadata +10 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b0da80bb866c35b8ab6548d017a9bc022831e3da0c5493b99aac0ba5c8c79cad
4
- data.tar.gz: 24bfacd140e3976e30c88204db5e33566c42dbd5e45d568c8d857a7a4205951d
3
+ metadata.gz: 5e756461a913daedaa92add1abd2adea7b443c3b464a69d9f886b0b42ee1d494
4
+ data.tar.gz: a2d43fab802f77cbce983be5428c179589cfcded1ee9f86f8b4e8a199b68653c
5
5
  SHA512:
6
- metadata.gz: 5c1fbddf259fce9fa65c6f0613ec5d46e271ab0c7212380bc86cb5fef6fb85a2f74b6c20a4fb6b4c0e1dacc6b8ad11e1c963f8827c997e88bb319cce157d305b
7
- data.tar.gz: a2363786904df0631c54b8d84094179b61607e300a16ba53cd6406b02272e51f1e21060832f5b64a3eeaaba1ff6dba7c8462d3308732f335dc363df666058120
6
+ metadata.gz: 99c357cf6e1a3b3966a780ec8a8fbefb51949bda85fc2b512919f893c31b1a4b5c8a0cd8595209a8ebfb38e6f156ee52c1b5e51b6422a603337c5484a7356b20
7
+ data.tar.gz: 2595257307c5b56c8e13dba00956f2e2d51f62046c935bd7cda7e4194a25a2c2b8e9350e0b70a2d6967ea2afa06c79b1d096d970dcd27c903a0fcbbe5dfbc271
@@ -2,6 +2,12 @@ require 'rspec/core'
2
2
 
3
3
  module Pundit
4
4
  module Matchers
5
+ require 'pundit/matchers/utils/policy_info'
6
+ require 'pundit/matchers/utils/all_actions/forbidden_actions_error_formatter'
7
+ require 'pundit/matchers/utils/all_actions/forbidden_actions_matcher'
8
+ require 'pundit/matchers/utils/all_actions/permitted_actions_error_formatter'
9
+ require 'pundit/matchers/utils/all_actions/permitted_actions_matcher'
10
+
5
11
  class Configuration
6
12
  attr_accessor :user_alias
7
13
 
@@ -364,6 +370,30 @@ module Pundit
364
370
  .inspect + '.'
365
371
  end
366
372
  end
373
+
374
+ RSpec::Matchers.define :permit_all_actions do
375
+ match do |policy|
376
+ @matcher = Pundit::Matchers::Utils::AllActions::PermittedActionsMatcher.new(policy)
377
+ @matcher.match?
378
+ end
379
+
380
+ failure_message do
381
+ formatter = Pundit::Matchers::Utils::AllActions::PermittedActionsErrorFormatter.new(@matcher)
382
+ formatter.message
383
+ end
384
+ end
385
+
386
+ RSpec::Matchers.define :forbid_all_actions do
387
+ match do |policy|
388
+ @matcher = Pundit::Matchers::Utils::AllActions::ForbiddenActionsMatcher.new(policy)
389
+ @matcher.match?
390
+ end
391
+
392
+ failure_message do
393
+ formatter = Pundit::Matchers::Utils::AllActions::ForbiddenActionsErrorFormatter.new(@matcher)
394
+ formatter.message
395
+ end
396
+ end
367
397
  end
368
398
 
369
399
  if defined?(Pundit)
metadata CHANGED
@@ -1,19 +1,22 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pundit-matchers
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.0
4
+ version: 1.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Alley
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-07-04 00:00:00.000000000 Z
11
+ date: 2022-11-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec-rails
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '3.0'
17
20
  - - ">="
18
21
  - !ruby/object:Gem::Version
19
22
  version: 3.0.0
@@ -21,6 +24,9 @@ dependencies:
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '3.0'
24
30
  - - ">="
25
31
  - !ruby/object:Gem::Version
26
32
  version: 3.0.0
@@ -51,7 +57,7 @@ extensions: []
51
57
  extra_rdoc_files: []
52
58
  files:
53
59
  - lib/pundit/matchers.rb
54
- homepage: http://github.com/chrisalley/pundit-matchers
60
+ homepage: http://github.com/punditcommunity/pundit-matchers
55
61
  licenses:
56
62
  - MIT
57
63
  metadata: {}
@@ -70,7 +76,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
70
76
  - !ruby/object:Gem::Version
71
77
  version: '0'
72
78
  requirements: []
73
- rubygems_version: 3.2.15
79
+ rubygems_version: 3.3.7
74
80
  signing_key:
75
81
  specification_version: 4
76
82
  summary: RSpec matchers for Pundit policies