wildcard_matchers 0.0.1 → 0.0.2
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.
- data/.travis.yml +4 -0
- data/CHANGELOG.md +6 -0
- data/README.md +1 -1
- data/Rakefile +8 -0
- data/VERSION +1 -1
- data/lib/wildcard_matchers.rb +4 -0
- data/spec/wildcard_matchers_spec.rb +6 -0
- metadata +4 -2
data/.travis.yml
ADDED
data/CHANGELOG.md
ADDED
data/README.md
CHANGED
data/Rakefile
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.2
|
data/lib/wildcard_matchers.rb
CHANGED
@@ -32,6 +32,8 @@ module WildcardMatchers
|
|
32
32
|
|
33
33
|
# TODO: class ArrayMatcher ?
|
34
34
|
def check_array(actual, expected, position, &on_failure)
|
35
|
+
return false unless actual.is_a?(Array)
|
36
|
+
|
35
37
|
if expected.size == actual.size
|
36
38
|
actual.zip(expected).map.with_index do |(a, e), index|
|
37
39
|
recursive_match(a, e, position + "[#{index}]", &on_failure)
|
@@ -48,6 +50,8 @@ _MESSAGE_
|
|
48
50
|
|
49
51
|
# TODO: class HashMatcher ?
|
50
52
|
def check_hash(actual, expected, position, &on_failure)
|
53
|
+
return false unless actual.is_a?(Hash)
|
54
|
+
|
51
55
|
if (actual.keys - expected.keys).size == 0 && (expected.keys - actual.keys).size == 0
|
52
56
|
expected.map do |key, value|
|
53
57
|
recursive_match(actual[key], value, position + "[#{key.inspect}]", &on_failure)
|
@@ -18,6 +18,12 @@ describe target do
|
|
18
18
|
it_should_behave_like "wildcard match", actual, expected
|
19
19
|
end
|
20
20
|
|
21
|
+
[ [ {}, [] ],
|
22
|
+
[ [], {} ],
|
23
|
+
].each do |actual, expected|
|
24
|
+
it_should_behave_like "not wildcard match", actual, expected
|
25
|
+
end
|
26
|
+
|
21
27
|
context "matches recursively in Array" do
|
22
28
|
[ [ [ 1, 2, "3"], [ Integer, Integer, String ] ],
|
23
29
|
[ [ 1, 2, [ 1 ] ], [ Integer, Integer, [ Integer ] ] ],
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wildcard_matchers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-05-
|
12
|
+
date: 2012-05-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -85,6 +85,8 @@ files:
|
|
85
85
|
- .gitignore
|
86
86
|
- .rspec
|
87
87
|
- .rvmrc
|
88
|
+
- .travis.yml
|
89
|
+
- CHANGELOG.md
|
88
90
|
- Gemfile
|
89
91
|
- LICENSE
|
90
92
|
- README.md
|