wildcard_matchers 0.0.4 → 0.1.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.
data/CHANGELOG.md CHANGED
@@ -1,3 +1,14 @@
1
+ ## 0.1.0
2
+ * big refactoring
3
+
4
+ ## 0.0.4
5
+ * BUGFIX
6
+ * renamed all to for_all
7
+
8
+ ## 0.0.3
9
+ * ENHANCEMENT
10
+ * add helper nil_or
11
+
1
12
  ## 0.0.2
2
13
  * BUGFIX
3
14
  * bug fix comparing Hash with Array
data/README.md CHANGED
@@ -1,11 +1,11 @@
1
- # wildcard_matchers [![Build Status](https://secure.travis-ci.org/okitan/wildcard_matchers.png?branch=master)](http://travis-ci.org/okitan/wildcard_matchers)
1
+ # wildcard_matchers [![Build Status](https://secure.travis-ci.org/okitan/wildcard_matchers.png?branch=master)](http://travis-ci.org/okitan/wildcard_matchers) [![Dependency Status](https://gemnasium.com/okitan/capybara-json.png)](https://gemnasium.com/okitan/capybara-json)
2
2
 
3
3
  ## General Usage
4
4
 
5
5
  ```ruby
6
6
  require "wildcard_matchers"
7
7
 
8
- WildcardMatchers.wild_card_match("string", /str/) #=> true
8
+ WildcardMatchers.wildcard_match?("string", /str/) #=> true
9
9
 
10
10
  require "wildcard_matchers/rspec"
11
11
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.4
1
+ 0.1.0
@@ -0,0 +1,18 @@
1
+ module WildcardMatchers
2
+ module Helpers
3
+ def for_all(expectation, &block)
4
+ expectation = block_given? ? block : expectation
5
+
6
+ ForAll.new(expectation)
7
+ end
8
+
9
+ class ForAll < ::WildcardMatchers::WildcardMatcher
10
+ protected
11
+ def wildcard_match(actual)
12
+ actual.each.with_index do |e, i|
13
+ errors.push(*self.class.superclass.check_errors(e, expectation, position + "[#{i}]"))
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,18 @@
1
+ module WildcardMatchers
2
+ module Helpers
3
+ def nil_or(expectation, &block)
4
+ expectation = block_given? ? block : expectation
5
+
6
+ NilOr.new(expectation)
7
+ end
8
+
9
+ class NilOr < ::WildcardMatchers::WildcardMatcher
10
+ protected
11
+ def wildcard_match(actual)
12
+ unless actual.nil?
13
+ errors.push(*self.class.superclass.check_errors(actual, expectation, position))
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -1,20 +1,7 @@
1
- module WildcardMatchers
1
+ module WildcardMathcers
2
2
  module Helpers
3
- def nil_or(expected, &on_failure)
4
- lambda do |actual|
5
- nil === actual or wildcard_match?(actual, expected, &on_failure)
6
- end
7
- end
8
-
9
- def for_all(expected = nil, &on_failure)
10
- raise "expected or block is mandatory" unless expected or block_given?
11
-
12
- expected ||= block
13
- lambda do |actual|
14
- actual.all? do |item|
15
- wildcard_match?(item, expected, &on_failure)
16
- end
17
- end
18
- end
19
3
  end
20
4
  end
5
+
6
+ require "wildcard_matchers/helpers/for_all"
7
+ require "wildcard_matchers/helpers/nil_or"
@@ -0,0 +1,28 @@
1
+ module WildcardMatchers
2
+ module Matchers
3
+ # RSpeck::Mocks has hash_including
4
+ def hash_includes(*args)
5
+ HashIncludes.new(args)
6
+ end
7
+
8
+ class HashIncludes < ::WildcardMatchers::WildcardMatcher
9
+ protected
10
+ def wildcard_match(actual)
11
+ unless actual.is_a?(Hash)
12
+ erros.push "#{position}: expect #{actual} to Hash"
13
+ end
14
+
15
+ hash_to_match = {}
16
+ hash_to_match = expectation.pop if expectation.last.is_a?(Hash)
17
+
18
+ expectation.each do |key|
19
+ errors << "#{position}: expect #{actual} to have key #{key}" unless actual.has_key?(key)
20
+ end
21
+
22
+ hash_to_match.each do |key, value|
23
+ errors.push(*self.class.superclass.check_errors(actual[key], value, position + "[#{key.inspect}]"))
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -23,17 +23,6 @@ module WildcardMatchers
23
23
  end
24
24
  end
25
25
 
26
- # RSpeck::Mocks has hash_including
27
- def hash_includes(*args)
28
- hash_to_match = {}
29
- hash_to_match = args.pop if args.last.is_a?(Hash)
30
-
31
- lambda do |hash|
32
- (args - hash.keys).size == 0 &&
33
- hash_to_match.all? {|key, value| value === hash[key] }
34
- end
35
- end
36
-
37
26
  def is_a_member_of(*args)
38
27
  lambda do |item|
39
28
  args.flatten.any? {|expected| expected === item }
@@ -41,3 +30,5 @@ module WildcardMatchers
41
30
  end
42
31
  end
43
32
  end
33
+
34
+ require "wildcard_matchers/matchers/hash_includes.rb"
@@ -7,15 +7,11 @@ end
7
7
 
8
8
  RSpec::Matchers.define :wildcard_match do |expected|
9
9
  match do |actual|
10
- WildcardMatchers.wildcard_match?(actual, expected)
10
+ @matcher = WildcardMatchers::WildcardMatcher.new(expected)
11
+ @matcher === actual
11
12
  end
12
13
 
13
14
  failure_message_for_should do |actual|
14
- failures = [ default_failure_message_for_should ]
15
- on_failure = proc {|message| failures << message }
16
-
17
- WildcardMatchers.wildcard_match?(actual, expected, &on_failure)
18
-
19
- failures.join("\n")
15
+ @matcher.errors.join("\n")
20
16
  end
21
17
  end
@@ -0,0 +1,90 @@
1
+ module WildcardMatchers
2
+ class WildcardMatcher
3
+ attr_reader :expectation, :errors
4
+ attr_accessor :position
5
+
6
+ def initialize(expectation = nil, position = ".", &block)
7
+ @expectation = (block_given? ? block : expectation)
8
+ @position = position
9
+ end
10
+
11
+ def ===(actual)
12
+ @errors = []
13
+ wildcard_match(actual)
14
+ errors.empty?
15
+ end
16
+
17
+ def self.check_errors(actual, expectation = nil, position = ".", &block)
18
+ expectation = (block_given? ? block : expectation)
19
+ matcher = self.new(expectation, position)
20
+ matcher === actual
21
+ matcher.errors
22
+ end
23
+
24
+ protected
25
+ def wildcard_match(actual)
26
+ case expectation
27
+ when self.class
28
+ expectation.position = position
29
+ expectation === actual
30
+ errors.push(*expectation.errors)
31
+ when Class
32
+ # fo Array or Hash Class
33
+ single_match(actual)
34
+ when Proc
35
+ # TODO: use sexp
36
+ single_match(actual)
37
+ when Array
38
+ errors.push(*ArrayMatcher.check_errors(actual, expectation, position))
39
+ when Hash
40
+ errors.push(*HashMatcher.check_errors(actual, expectation, position))
41
+ else
42
+ single_match(actual)
43
+ end
44
+ end
45
+
46
+ def single_match(actual)
47
+ unless expectation === actual
48
+ errors << "#{position}: expect #{actual.inspect} to #{expectation.inspect}"
49
+ end
50
+ end
51
+ end
52
+
53
+ class ArrayMatcher < WildcardMatcher
54
+ protected
55
+ def wildcard_match(actual)
56
+ unless actual.is_a?(Array)
57
+ errors << "#{position}: expect #{actual.inspect} to #{expectation.inspect}"
58
+ return
59
+ end
60
+
61
+ if expectation.size === actual.size
62
+ expectation.zip(actual).each.with_index do |(e, a), i|
63
+ errors.push(*self.class.superclass.check_errors(a, e, position + "[#{i}]"))
64
+ end
65
+ else
66
+ errors << "#{position}: expect Array size #{actual.size} to #{expectation.size}"
67
+ # TODO: diff-lcs
68
+ end
69
+ end
70
+ end
71
+
72
+ class HashMatcher < WildcardMatcher
73
+ protected
74
+ def wildcard_match(actual)
75
+ unless actual.is_a?(Hash)
76
+ errors << "#{position}: expect #{actual.inspect} to #{expectation.inspect}"
77
+ return
78
+ end
79
+
80
+ if (actual.keys - expectation.keys).size == 0 && (expectation.keys - actual.keys).size == 0
81
+ expectation.each do |key, value|
82
+ errors.push(*self.class.superclass.check_errors(actual[key], value, position + "[#{key.inspect}]"))
83
+ end
84
+ else
85
+ errors << "#{position}: expect Hash keys #{actual.keys} to #{expectation.keys}"
86
+ #TODO: diff-lcs
87
+ end
88
+ end
89
+ end
90
+ end
@@ -1,72 +1,20 @@
1
- require "wildcard_matchers/helpers"
2
- require "wildcard_matchers/matchers"
3
-
4
1
  module WildcardMatchers
2
+ autoload :Helpers, "wildcard_matchers/helpers"
3
+ autoload :Matchers, "wildcard_matchers/matchers"
4
+ autoload :WildcardMatcher, "wildcard_matchers/wildcard_matcher"
5
+
5
6
  include Helpers
6
7
  include Matchers
7
8
 
8
9
  def wildcard_match?(actual, expected, &on_failure)
9
- on_failure = proc { return false } unless block_given?
10
-
11
- recursive_match(actual, expected, &on_failure)
12
- end
13
-
14
- protected
15
- def recursive_match(actual, expected, position = ".", &on_failure)
16
- # "case expected" should omit Array or Hash
17
- # "case actual" should omit Proc
18
- case expected
19
- when Class
20
- # when expected is Array or Hash (Class) comes here and do nothing
21
- when Array
22
- return check_array(actual, expected, position, &on_failure)
23
- when Hash
24
- return check_hash(actual, expected, position, &on_failure)
25
- end
10
+ errors = WildcardMatcher.check_errors(actual, expected)
26
11
 
27
- unless expected === actual
28
- yield("#{position}: expect #{actual.inspect} to #{expected.inspect}")
29
- false
30
- else
12
+ if errors.empty? #matcher.errors.empty?
31
13
  true
32
- end
33
- end
34
-
35
- # TODO: class ArrayMatcher ?
36
- def check_array(actual, expected, position, &on_failure)
37
- return false unless actual.is_a?(Array)
38
-
39
- if expected.size == actual.size
40
- actual.zip(expected).map.with_index do |(a, e), index|
41
- recursive_match(a, e, position + "[#{index}]", &on_failure)
42
- end.all?
43
14
  else
44
- yield <<_MESSAGE_
45
- #{position}: expect Array size #{actual.size} to #{expected.size}
46
- actual: #{actual.inspect}
47
- expect: #{expected.inspect}
48
- _MESSAGE_
15
+ on_failure.call(errors) if block_given?
49
16
  false
50
17
  end
51
18
  end
52
-
53
- # TODO: class HashMatcher ?
54
- def check_hash(actual, expected, position, &on_failure)
55
- return false unless actual.is_a?(Hash)
56
-
57
- if (actual.keys - expected.keys).size == 0 && (expected.keys - actual.keys).size == 0
58
- expected.map do |key, value|
59
- recursive_match(actual[key], value, position + "[#{key.inspect}]", &on_failure)
60
- end.all?
61
- else
62
- yield <<_MESSAGE_
63
- #{position}: expect Hash keys #{actual.size} to #{expected.size}
64
- +keys: #{actual.keys - expected.keys}
65
- -keys: #{expected.keys - actual.keys }
66
- _MESSAGE_
67
- false
68
- end
69
- end
70
-
71
19
  module_function *self.instance_methods
72
20
  end
data/spec/spec_helper.rb CHANGED
@@ -5,6 +5,7 @@ require "wildcard_matchers/rspec"
5
5
  Dir[File.expand_path("support/**/*.rb", File.dirname(__FILE__))].each {|f| require f }
6
6
 
7
7
  require "pry"
8
+ require "tapp"
8
9
 
9
10
  RSpec.configure do |config|
10
11
  config.treat_symbols_as_metadata_keys_with_true_values = true
@@ -14,4 +15,4 @@ end
14
15
  # global debug function
15
16
  # usage:
16
17
  # wildcard_match?(actual, expected, &$debug)
17
- $debug = proc {|message| puts message }
18
+ $debug = proc {|errors| puts errors }
@@ -0,0 +1,14 @@
1
+ require "spec_helper"
2
+
3
+ describe WildcardMatchers::Helpers::ForAll do
4
+ [ [ %w[ a b c ], :for_all, String ],
5
+ [ %w[ a b c ], :for_all, :is_a_string ],
6
+ [ %w[ a b c ], :for_all, :is_a, String ],
7
+ ].each do |actual, helper, matcher, *args|
8
+ it_behaves_like "wildcard match with helper", actual, helper, matcher, *args
9
+ end
10
+
11
+ it "should match using lambda with helper" do
12
+ [ 2, 4, 6].should wildcard_match(for_all ->(item) { item % 2 == 0 })
13
+ end
14
+ end
@@ -0,0 +1,11 @@
1
+ require "spec_helper"
2
+
3
+ describe WildcardMatchers::Helpers::NilOr do
4
+ [ [ nil, :nil_or, String ],
5
+ [ "aaa", :nil_or, String ],
6
+ [ nil, :nil_or, :is_a_string ],
7
+ [ "aaa", :nil_or, :is_a_string ],
8
+ ].each do |actual, helper, matcher, *args|
9
+ it_behaves_like "wildcard match with helper", actual, helper, matcher, *args
10
+ end
11
+ end
@@ -0,0 +1,17 @@
1
+ require "spec_helper"
2
+
3
+ describe WildcardMatchers::Matchers::HashIncludes do
4
+ [ [ { :a => 1, :b => 1, :c => 1 }, :hash_includes, :a, :b ],
5
+ [ { :a => 1, :b => 1, :c => 1 }, :hash_includes, :a, :b => 1 ],
6
+ [ { :a => 1, :b => 1, :c => 1 }, :hash_includes, :a, :b => Integer ],
7
+ ].each do |actual, matcher, *args|
8
+ it_behaves_like "wildcard match", actual, matcher, *args
9
+ end
10
+
11
+ [ [ { :a => 1, :b => 1, :c => 1 }, :hash_includes, :a, :d ],
12
+ [ { :a => 1, :b => 1, :c => 1 }, :hash_includes, :a, :b => 2 ],
13
+ [ { :a => 1, :b => 1, :c => 1 }, :hash_includes, :a, :b => String ],
14
+ ].each do |actual, matcher, *args|
15
+ it_behaves_like "not wildcard match", actual, matcher, *args
16
+ end
17
+ end
@@ -8,7 +8,7 @@ describe WildcardMatchers::Matchers do
8
8
  [ { :some => :hash }, Hash ],
9
9
  [ [ 1, 2, 3 ], Array ],
10
10
  ].each do |actual, expected|
11
- it_should_behave_like "wildcard match", actual, :is_a, expected
11
+ it_behaves_like "wildcard match", actual, :is_a, expected
12
12
  end
13
13
 
14
14
  [ [ "string", :is_a_string ],
@@ -27,29 +27,23 @@ describe WildcardMatchers::Matchers do
27
27
  [ "2012-05-10", :is_time ],
28
28
 
29
29
  ].each do |actual, matcher|
30
- it_should_behave_like "wildcard match", actual, matcher
30
+ it_behaves_like "wildcard match", actual, matcher
31
31
  end
32
32
 
33
33
  [ [ 0, :is_bool ],
34
34
  ].each do |actual, matcher|
35
- it_should_behave_like "not wildcard match", actual, matcher
35
+ it_behaves_like "not wildcard match", actual, matcher
36
36
  end
37
37
 
38
- [ [ { :a => 1, :b => 1, :c => 1 }, :hash_includes, :a, :b ],
39
- [ { :a => 1, :b => 1, :c => 1 }, :hash_includes, :a, :b => 1 ],
40
- [ { :a => 1, :b => 1, :c => 1 }, :hash_includes, :a, :b => Integer ],
41
- [ "a", :is_a_member_of, %w[ a b ] ],
38
+ [ [ "a", :is_a_member_of, %w[ a b ] ],
42
39
  [ "a", :is_a_member_of, [ String ] ],
43
40
  ].each do |actual, matcher, *args|
44
- it_should_behave_like "wildcard match", actual, matcher, *args
41
+ it_behaves_like "wildcard match", actual, matcher, *args
45
42
  end
46
43
 
47
- [ [ { :a => 1, :b => 1, :c => 1 }, :hash_includes, :a, :d ],
48
- [ { :a => 1, :b => 1, :c => 1 }, :hash_includes, :a, :b => 2 ],
49
- [ { :a => 1, :b => 1, :c => 1 }, :hash_includes, :a, :b => String ],
50
- [ "a", :is_a_member_of, %w[ b c ] ],
44
+ [ [ "a", :is_a_member_of, %w[ b c ] ],
51
45
  [ "a", :is_a_member_of, [ Integer ] ],
52
46
  ].each do |actual, matcher, *args|
53
- it_should_behave_like "not wildcard match", actual, matcher, *args
47
+ it_behaves_like "not wildcard match", actual, matcher, *args
54
48
  end
55
49
  end
@@ -18,8 +18,8 @@ describe "matcher wildcard_match" do
18
18
  [ [ 1, String, ".: expect 1 to String" ],
19
19
  [ [ 1 ], [ String ], ".[0]: expect 1 to String" ],
20
20
  [ [ 1 ], [], ".: expect Array size 1 to 0" ],
21
- [ { :a => 1 }, {}, "+keys: [:a]" ],
22
- [ {}, {:a => 1}, "-keys: [:a]" ],
21
+ # [ { :a => 1 }, {}, "+keys: [:a]" ],
22
+ # [ {}, {:a => 1}, "-keys: [:a]" ],
23
23
  [ { :a => 1}, {:a => 0}, ".[:a]: expect 1 to 0" ],
24
24
  ].each do |actual, expected, failure_message|
25
25
  it "not match #{actual.inspect} with #{expected} and return #{failure_message.inspect} as failure_message" do
@@ -15,20 +15,20 @@ describe target do
15
15
  [ { :some => :hash }, Hash ],
16
16
  [ [ 1, 2, 3 ], Array ],
17
17
  ].each do |actual, expected|
18
- it_should_behave_like "wildcard match", actual, expected
18
+ it_behaves_like "wildcard match", actual, expected
19
19
  end
20
20
 
21
21
  [ [ {}, [] ],
22
22
  [ [], {} ],
23
23
  ].each do |actual, expected|
24
- it_should_behave_like "not wildcard match", actual, expected
24
+ it_behaves_like "not wildcard match", actual, expected
25
25
  end
26
26
 
27
27
  context "matches recursively in Array" do
28
28
  [ [ [ 1, 2, "3"], [ Integer, Integer, String ] ],
29
29
  [ [ 1, 2, [ 1 ] ], [ Integer, Integer, [ Integer ] ] ],
30
30
  ].each do |actual, expected|
31
- it_should_behave_like "wildcard match", actual, expected
31
+ it_behaves_like "wildcard match", actual, expected
32
32
  end
33
33
  end
34
34
 
@@ -37,7 +37,7 @@ describe target do
37
37
  [ [ 1, 2, 3 ], [ Integer, String, Integer ] ],
38
38
  [ [ 1, 2, [ 1 ] ], [ Integer, Integer, [ String ] ] ],
39
39
  ].each do |actual, expected|
40
- it_should_behave_like "not wildcard match", actual, expected
40
+ it_behaves_like "not wildcard match", actual, expected
41
41
  end
42
42
  end
43
43
 
@@ -45,7 +45,7 @@ describe target do
45
45
  [ [ { :hoge => "fuga", :fuga => "ugu" }, { :hoge => String, :fuga => String } ],
46
46
  [ { :hoge => "fuga", :fuga => { :ugu => "piyo" } }, { :hoge => String, :fuga => { :ugu => String } } ],
47
47
  ].each do |actual, expected|
48
- it_should_behave_like "wildcard match", actual, expected
48
+ it_behaves_like "wildcard match", actual, expected
49
49
  end
50
50
  end
51
51
 
@@ -56,7 +56,7 @@ describe target do
56
56
  [ { :hoge => "fuga", :fuga => { :ugu => "piyo" } }, { :hoge => String, :fuga => { :ugu => Integer } } ],
57
57
  [ { :hoge => "fuga", :fuga => { :ugu => "piyo" } }, { :hoge => String, :fuga => { :fuga => String } } ],
58
58
  ].each do |actual, expected|
59
- it_should_behave_like "not wildcard match", actual, expected
59
+ it_behaves_like "not wildcard match", actual, expected
60
60
  end
61
61
  end
62
62
 
@@ -69,7 +69,7 @@ describe target do
69
69
  { :first => Integer, :second => [ Integer ], :third => { :one => Integer } }
70
70
  ]
71
71
  ].each do |actual, expected|
72
- it_should_behave_like "wildcard match", actual, expected
72
+ it_behaves_like "wildcard match", actual, expected
73
73
  end
74
74
  end
75
75
  end
@@ -80,21 +80,20 @@ describe target do
80
80
  expected = false
81
81
 
82
82
  failure = nil
83
- wildcard_match?(actual, expected) {|message| failure = message }
84
- failure.should =~ /#{actual.inspect} .+ #{expected.inspect}/
83
+ wildcard_match?(actual, expected) {|errors| failure = errors }
84
+ failure.should wildcard_match([/#{actual.inspect} .+ #{expected.inspect}/])
85
85
  end
86
86
 
87
87
  it "can get several failure messages" do
88
88
  actual = [ 1, 0, 2 ]
89
89
  expected = [ 3, 0, 4 ]
90
90
 
91
- failures = []
92
- wildcard_match?(actual, expected) {|message| failures << message }
91
+ failure = nil
92
+ wildcard_match?(actual, expected) {|errors| failure = errors }
93
93
 
94
- # TODO: dog fooding of rspec-matcher
95
94
  expect_failures = [ /#{actual.first}.+#{expected.first}/,
96
95
  /#{actual.last}.+#{expected.last}/ ]
97
- wildcard_match?(failures, expect_failures, &$debug).should be_true
96
+ failure.should wildcard_match(expect_failures)
98
97
  end
99
98
 
100
99
  # TODO: more failure message
@@ -20,4 +20,5 @@ Gem::Specification.new do |gem|
20
20
 
21
21
  # for debug
22
22
  gem.add_development_dependency "pry"
23
+ gem.add_development_dependency "tapp"
23
24
  end
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
4
+ version: 0.1.0
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-30 00:00:00.000000000 Z
12
+ date: 2012-06-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -75,6 +75,22 @@ dependencies:
75
75
  - - ! '>='
76
76
  - !ruby/object:Gem::Version
77
77
  version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: tapp
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
78
94
  description: wildcard matchers
79
95
  email:
80
96
  - okitakunio@gmail.com
@@ -94,12 +110,18 @@ files:
94
110
  - VERSION
95
111
  - lib/wildcard_matchers.rb
96
112
  - lib/wildcard_matchers/helpers.rb
113
+ - lib/wildcard_matchers/helpers/for_all.rb
114
+ - lib/wildcard_matchers/helpers/nil_or.rb
97
115
  - lib/wildcard_matchers/matchers.rb
116
+ - lib/wildcard_matchers/matchers/hash_includes.rb
98
117
  - lib/wildcard_matchers/rspec.rb
118
+ - lib/wildcard_matchers/wildcard_matcher.rb
99
119
  - spec/spec.watchr
100
120
  - spec/spec_helper.rb
101
121
  - spec/support/shared_examples.rb
102
- - spec/wildcard_matchers/helpers_spec.rb
122
+ - spec/wildcard_matchers/helpers/for_all_spec.rb
123
+ - spec/wildcard_matchers/helpers/nil_or_spec.rb
124
+ - spec/wildcard_matchers/matchers/hash_includes_spec.rb
103
125
  - spec/wildcard_matchers/matchers_spec.rb
104
126
  - spec/wildcard_matchers/rspec_spec.rb
105
127
  - spec/wildcard_matchers_spec.rb
@@ -132,7 +154,9 @@ test_files:
132
154
  - spec/spec.watchr
133
155
  - spec/spec_helper.rb
134
156
  - spec/support/shared_examples.rb
135
- - spec/wildcard_matchers/helpers_spec.rb
157
+ - spec/wildcard_matchers/helpers/for_all_spec.rb
158
+ - spec/wildcard_matchers/helpers/nil_or_spec.rb
159
+ - spec/wildcard_matchers/matchers/hash_includes_spec.rb
136
160
  - spec/wildcard_matchers/matchers_spec.rb
137
161
  - spec/wildcard_matchers/rspec_spec.rb
138
162
  - spec/wildcard_matchers_spec.rb
@@ -1,18 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe WildcardMatchers::Helpers do
4
- [ [ nil, :nil_or, String ],
5
- [ "aaa", :nil_or, String ],
6
- [ nil, :nil_or, :is_a_string ],
7
- [ "aaa", :nil_or, :is_a_string ],
8
- [ %w[ a b c ], :for_all, String ],
9
- [ %w[ a b c ], :for_all, :is_a_string ],
10
- [ %w[ a b c ], :for_all, :is_a, String ],
11
- ].each do |actual, helper, matcher, *args|
12
- it_should_behave_like "wildcard match with helper", actual, helper, matcher, *args
13
- end
14
-
15
- it "should match using lambda with helper" do
16
- [ 2, 4, 6].should wildcard_match(for_all ->(item) { item % 2 == 0 })
17
- end
18
- end