wildcard_matchers 0.4.0 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +7 -0
- data/VERSION +1 -1
- data/lib/wildcard_matchers/helpers/all_of.rb +5 -0
- data/lib/wildcard_matchers/helpers/any_of.rb +5 -0
- data/lib/wildcard_matchers/wildcard_matcher.rb +8 -0
- data/spec/wildcard_matchers/matchers_spec.rb +50 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 505f14ca6ec4c6425c12be433c23de1833b7bb25
|
4
|
+
data.tar.gz: 85a7da4a4bb5703dd721ffeff73c977bc9f7cc3f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cf5f6f22000d88c77f55591d5dd76e6bed1258c29695180cb78e5c94150ad354908d9a1085534348749f2515c0f6c508fcdea62c0d84f06d7e0fd6e367ba81af
|
7
|
+
data.tar.gz: 9444ae631b08f452de853539e0a16ed0a795d4132dfdcac713ce798bc29b5a606c5cd45d5e979a8eaed6b1e38440e7c2dc17ea71b0fdb4cc77d9c4397eecf930
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -62,6 +62,13 @@ See specs, for more detail.
|
|
62
62
|
* responding
|
63
63
|
* responding(next: 2) === 1 #=> true (because 1.next #=> 2)
|
64
64
|
|
65
|
+
### composite matchers
|
66
|
+
|
67
|
+
* using &
|
68
|
+
* for_all(is_a_string) & for_any(/hoge/) # every element is String and one matched /hoge/
|
69
|
+
* using |
|
70
|
+
* for_all(is_a_string) | for_all(is_a_integer) # every element is String or Integer
|
71
|
+
|
65
72
|
## How it works
|
66
73
|
|
67
74
|
It is very simple. Recursive match using ===, and Class, Range, and Proc act as wildcard matchers.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.9.0
|
@@ -8,6 +8,14 @@ module WildcardMatchers
|
|
8
8
|
@position = position
|
9
9
|
end
|
10
10
|
|
11
|
+
def &(matcher)
|
12
|
+
WildcardMatchers::Helpers::AllOf.new([self, matcher])
|
13
|
+
end
|
14
|
+
|
15
|
+
def |(matcher)
|
16
|
+
WildcardMatchers::Helpers::AnyOf.new([self, matcher])
|
17
|
+
end
|
18
|
+
|
11
19
|
def ===(actual)
|
12
20
|
@errors = []
|
13
21
|
wildcard_match_with_catch_exception(actual)
|
@@ -46,4 +46,54 @@ describe WildcardMatchers::Matchers do
|
|
46
46
|
].each do |actual, matcher, *args|
|
47
47
|
it_behaves_like "not wildcard match", actual, matcher, *args
|
48
48
|
end
|
49
|
+
|
50
|
+
context "composing matchers" do
|
51
|
+
context "with &" do
|
52
|
+
include WildcardMatchers
|
53
|
+
|
54
|
+
it "works" do
|
55
|
+
matcher = responding(size: 2) & /a/ & /b/
|
56
|
+
expect(wildcard_match?("ab", matcher, &debugger)).to be true
|
57
|
+
end
|
58
|
+
|
59
|
+
it "shows every erro4" do
|
60
|
+
matcher = responding(size: 2) & /a/ & /b/
|
61
|
+
expect(wildcard_match?("c", matcher, &debugger)).to be false
|
62
|
+
end
|
63
|
+
|
64
|
+
it "returns error just one mismatch" do
|
65
|
+
matcher = responding(size: 1) & /a/ & /b/
|
66
|
+
expect(wildcard_match?("a", matcher, &debugger)).to be false
|
67
|
+
end
|
68
|
+
|
69
|
+
it "is also available for all_of" do
|
70
|
+
matcher = all_of([String, /a/]) & /b/
|
71
|
+
expect(wildcard_match?("a", matcher, &debugger)).to be false
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
context "with |" do
|
76
|
+
include WildcardMatchers
|
77
|
+
|
78
|
+
it "works" do
|
79
|
+
matcher = responding(size: 2) | /a/ | /b/
|
80
|
+
expect(wildcard_match?("a", matcher, &debugger)).to be true
|
81
|
+
end
|
82
|
+
|
83
|
+
it "shows every error" do
|
84
|
+
matcher = responding(size: 2) | /a/ | /b/
|
85
|
+
expect(wildcard_match?("c", matcher, &debugger)).to be false
|
86
|
+
end
|
87
|
+
|
88
|
+
it "is also available for any_of" do
|
89
|
+
matcher = any_of([Integer, /a/]) | /b/
|
90
|
+
expect(wildcard_match?("b", matcher, &debugger)).to be true
|
91
|
+
end
|
92
|
+
|
93
|
+
it "is also available for any_of" do
|
94
|
+
matcher = any_of([Integer, /b/]) | /a/
|
95
|
+
expect(wildcard_match?("b", matcher, &debugger)).to be true
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
49
99
|
end
|