wildcard_matchers 0.2.1 → 0.3.0
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/CHANGELOG.md +4 -0
- data/README.md +2 -0
- data/VERSION +1 -1
- data/lib/wildcard_matchers/wildcard_matcher.rb +13 -0
- data/spec/spec_helper.rb +0 -1
- data/spec/wildcard_matchers_spec.rb +2 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 68dd29b55f94a55eda5bb24f053ea9f42c6701e4
|
4
|
+
data.tar.gz: 382aabd7935d156693a70bb9c0b695e4bd90a1b7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4ad2caeaf6898e7770b0364e36c2657961f4fa50e9bd76f2fc50c5a761245076aec7c897778aa3439ff3dd3c6225e84c8c5986cb81a81733468dcd83d3e4afd6
|
7
|
+
data.tar.gz: 9895719d8c2bcbb43869b6043a0c84e61146fca6a4c0fb3e7b26fbf87d59c180446c6de2846c67ab62f4ed33dcaffb12b3d1d27e5e6c372e25e38d18dd953821
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -42,6 +42,8 @@ See specs, for more detail.
|
|
42
42
|
* hash_includes(:a => 2) === { :a => 1 } #=> false
|
43
43
|
* is_a_member_of
|
44
44
|
* is_a_member_of(0, 1) === 0 #=> true
|
45
|
+
* bag_of
|
46
|
+
* sored array comparison (Note: each item should comparable with every other item)
|
45
47
|
|
46
48
|
### helpers
|
47
49
|
* nil_or
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.3.0
|
@@ -41,6 +41,8 @@ module WildcardMatchers
|
|
41
41
|
when Proc
|
42
42
|
# TODO: use sexp
|
43
43
|
single_match(actual)
|
44
|
+
when Method
|
45
|
+
errors.push(*MethodMatcher.check_errors(actual, expectation, position))
|
44
46
|
when Array
|
45
47
|
errors.push(*ArrayMatcher.check_errors(actual, expectation, position))
|
46
48
|
when Hash
|
@@ -102,4 +104,15 @@ module WildcardMatchers
|
|
102
104
|
end
|
103
105
|
end
|
104
106
|
end
|
107
|
+
|
108
|
+
class MethodMatcher < WildcardMatcher
|
109
|
+
protected
|
110
|
+
def wildcard_match(actual)
|
111
|
+
result = expectation.call(actual)
|
112
|
+
|
113
|
+
unless result
|
114
|
+
errors << "#{position}: expect #{expectation.receiver.inspect}.#{expectation.name} return true but #{result}"
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
105
118
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -14,6 +14,8 @@ describe target do
|
|
14
14
|
[ 0, Numeric ], # superclass
|
15
15
|
[ { :some => :hash }, Hash ],
|
16
16
|
[ [ 1, 2, 3 ], Array ],
|
17
|
+
[ 1, ->(v) { [1,2,3].include?(v) } ],
|
18
|
+
[ 1, [1,2,3].method(:include?) ],
|
17
19
|
].each do |actual, expected|
|
18
20
|
it_behaves_like "wildcard match", actual, expected
|
19
21
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wildcard_matchers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- okitan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-07-
|
11
|
+
date: 2015-07-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: facets
|