wildcard_matchers 0.2.1 → 0.3.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
  SHA1:
3
- metadata.gz: 3c38dfa86fa011bfe6cedf7cd72b5d44144666ca
4
- data.tar.gz: 22af55c3ae96ea0ee671c22f576b7155e220dec5
3
+ metadata.gz: 68dd29b55f94a55eda5bb24f053ea9f42c6701e4
4
+ data.tar.gz: 382aabd7935d156693a70bb9c0b695e4bd90a1b7
5
5
  SHA512:
6
- metadata.gz: 643a3bb8994f1cd26c2c06152539e55322086acd94498e53e4f534670b020b107186d023bf17ac8dc8dd640dd3afa20cc8a148ba5e6f1a814abeea73ced0854c
7
- data.tar.gz: 8ca9ad272f497cd2c21d3f8a00ca4e82c16f1add74023291a124d7fc18e3ee44f3320b86f58c9c2d783583d69be99af2b4ef56bcc8df2a881430d7c59a67ab33
6
+ metadata.gz: 4ad2caeaf6898e7770b0364e36c2657961f4fa50e9bd76f2fc50c5a761245076aec7c897778aa3439ff3dd3c6225e84c8c5986cb81a81733468dcd83d3e4afd6
7
+ data.tar.gz: 9895719d8c2bcbb43869b6043a0c84e61146fca6a4c0fb3e7b26fbf87d59c180446c6de2846c67ab62f4ed33dcaffb12b3d1d27e5e6c372e25e38d18dd953821
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.3.0
2
+ * ENHANCEMENT
3
+ * allow method object
4
+
1
5
  ## 0.2.1
2
6
  * ENHANCEMENT
3
7
  * add bag_of like Test::Deep in perl
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.2.1
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
@@ -11,7 +11,6 @@ require 'coveralls'
11
11
  Coveralls.wear!
12
12
 
13
13
  RSpec.configure do |config|
14
- config.treat_symbols_as_metadata_keys_with_true_values = true
15
14
  config.run_all_when_everything_filtered = true
16
15
  end
17
16
 
@@ -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.2.1
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-21 00:00:00.000000000 Z
11
+ date: 2015-07-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: facets