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 +4 -4
- data/README.md +2 -0
- data/lib/banken/matchers.rb +44 -0
- data/lib/banken/matchers/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cec9aa1fec4dfeb1c64673460e2e63e8807e1cbfc1cd54dcca96e343a6bb562d
|
4
|
+
data.tar.gz: 02576abaaccce60829fc814eee2681292c272fed9255e17256724fa66cb338ab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 88805ed3f23889a0a80633b958943afc93d92da80f57afc3364fe4047c152b5064b63ef288a741dfcf4567f40ec012802eff0321d5cd644be747a858f644ec21
|
7
|
+
data.tar.gz: 552250e2bf356e277ef13d4c3dc84e4f238ad6a13df8b2275c58821d8847c23eebe9839614a4bf22ebd44d1210ba613522ca66d2f6b6c65947080df31a961dca
|
data/README.md
CHANGED
data/lib/banken/matchers.rb
CHANGED
@@ -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
|
+
}
|
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.
|
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-
|
11
|
+
date: 2020-07-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|