banken-matchers 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ab7b5ac381df0185252eaf5d4a0921812915d3b4b4373d3f8164affb266b2189
4
- data.tar.gz: b2979af162c303ede5ecb4847129a77ee4bb979c85b5ef348b22bb7642a2d1ca
3
+ metadata.gz: cec9aa1fec4dfeb1c64673460e2e63e8807e1cbfc1cd54dcca96e343a6bb562d
4
+ data.tar.gz: 02576abaaccce60829fc814eee2681292c272fed9255e17256724fa66cb338ab
5
5
  SHA512:
6
- metadata.gz: 8592ff3e33aa6ebd0b5df6940d03b20315d802bcdc085fa7045ea32044c91ec3d680af7f401821c6878c058a37d18fd36b4a9c7e52d2811157fb911f239d30e6
7
- data.tar.gz: 3f01c53b709a5fac517326b4d8339ec5122f94ecde06c04c58735576ec390d0534f189fed1d25717b4d6c8e0f3eba1d86bc167757b6980ccce546cad77357378
6
+ metadata.gz: 88805ed3f23889a0a80633b958943afc93d92da80f57afc3364fe4047c152b5064b63ef288a741dfcf4567f40ec012802eff0321d5cd644be747a858f644ec21
7
+ data.tar.gz: 552250e2bf356e277ef13d4c3dc84e4f238ad6a13df8b2275c58821d8847c23eebe9839614a4bf22ebd44d1210ba613522ca66d2f6b6c65947080df31a961dca
data/README.md CHANGED
@@ -32,6 +32,8 @@ end
32
32
 
33
33
  - `permit_action(:action_name)`
34
34
  - `forbid_action(:action_name)`
35
+ - `permit_actions(:action_name1, :action_name2, ...)`
36
+ - `forbid_actions(:action_name1, :action_name2, ...)`
35
37
 
36
38
  ## Example
37
39
 
@@ -43,3 +43,47 @@ RSpec::Matchers.define(:forbid_action) { |action|
43
43
  "#{loyalty.class} does not forbid #{action} for #{loyalty.public_send(Banken::Matchers.configuration.user_alias).inspect}."
44
44
  }
45
45
  }
46
+
47
+ RSpec::Matchers.define(:permit_actions) { |*actions|
48
+ include Banken::Matchers
49
+
50
+ match { |loyalty|
51
+ return false if actions.count.zero?
52
+
53
+ @forbidden_actions = actions.select do |action|
54
+ ! loyalty.public_send "#{action}?"
55
+ end
56
+
57
+ @forbidden_actions.empty?
58
+ }
59
+
60
+ failure_message { |loyalty|
61
+ if actions.count.zero?
62
+ "At least one action must be specified when using the permit_actions matcher."
63
+ else
64
+ "#{loyalty.class} expected to permit #{actions}, but forbade #{@forbidden_actions} for #{loyalty.public_send(Banken::Matchers.configuration.user_alias).inspect}."
65
+ end
66
+ }
67
+ }
68
+
69
+ RSpec::Matchers.define(:forbid_actions) { |*actions|
70
+ include Banken::Matchers
71
+
72
+ match { |loyalty|
73
+ return false if actions.count.zero?
74
+
75
+ @permitted_actions = actions.select do |action|
76
+ loyalty.public_send "#{action}?"
77
+ end
78
+
79
+ @permitted_actions.empty?
80
+ }
81
+
82
+ failure_message { |loyalty|
83
+ if actions.count.zero?
84
+ "At least one action must be specified when using the forbid_actions matcher."
85
+ else
86
+ "#{loyalty.class} expected to forbade #{actions}, but permitted #{@permitted_actions} for #{loyalty.public_send(Banken::Matchers.configuration.user_alias).inspect}."
87
+ end
88
+ }
89
+ }
@@ -1,5 +1,5 @@
1
1
  module Banken
2
2
  module Matchers
3
- VERSION = "0.1.0"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: banken-matchers
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ichi
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-07-20 00:00:00.000000000 Z
11
+ date: 2020-07-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake