wildcard_matchers 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
data/.travis.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  rvm:
2
2
  - 1.9.2
3
3
  - 1.9.3
4
- - ruby-head
4
+ - 2.0.0
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ ## 0.1.3
2
+ * more error handling
3
+
1
4
  ## 0.1.2
2
5
  * minor bug fix and refactoring
3
6
 
data/README.md CHANGED
@@ -1,4 +1,4 @@
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)
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/wildcard_matchers.png)](https://gemnasium.com/okitan/wildcard_matchers)
2
2
 
3
3
  ## General Usage
4
4
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.2
1
+ 0.1.3
@@ -6,8 +6,9 @@ module WildcardMatchers
6
6
  class HashIncludes < ::WildcardMatchers::WildcardMatcher
7
7
  protected
8
8
  def wildcard_match(actual)
9
- unless actual.is_a?(Hash)
10
- errors.push "#{position}: expect #{actual} to Hash"
9
+ unless actual && actual.is_a?(Hash)
10
+ errors.push "#{position}: expect #{actual.inspect} to Hash"
11
+ return
11
12
  end
12
13
 
13
14
  hash_to_match = {}
@@ -7,12 +7,17 @@ module WildcardMatchers
7
7
  class IsUri < ::WildcardMatchers::WildcardMatcher
8
8
  protected
9
9
  def wildcard_match(actual)
10
+ unless actual
11
+ errors.push "#{position}: expect uri but nil"
12
+ return
13
+ end
14
+
10
15
  uri = nil
11
16
  begin
12
17
  require "addressable/uri"
13
18
  uri = ::Addressable::URI.parse(actual) # if actual is ::URI re-parse
14
19
  rescue LoadError
15
- require "uri".tapp
20
+ require "uri"
16
21
  uri = actual.is_a?(::URI) ? actual : ::URI.parse(actual)
17
22
  end
18
23
 
@@ -10,7 +10,7 @@ module WildcardMatchers
10
10
 
11
11
  def ===(actual)
12
12
  @errors = []
13
- wildcard_match(actual)
13
+ wildcard_match_with_catch_exception(actual)
14
14
  errors.empty?
15
15
  end
16
16
 
@@ -22,6 +22,13 @@ module WildcardMatchers
22
22
  end
23
23
 
24
24
  protected
25
+ # I'd like to use prepend
26
+ def wildcard_match_with_catch_exception(actual)
27
+ wildcard_match(actual)
28
+ rescue => e
29
+ errors.push "#{position}: <#{e.inspect}:#{e.message}> for expect #{actual.inspect} to #{expectation.inspect}"
30
+ end
31
+
25
32
  def wildcard_match(actual)
26
33
  case expectation
27
34
  when self.class
@@ -53,7 +60,7 @@ module WildcardMatchers
53
60
  class ArrayMatcher < WildcardMatcher
54
61
  protected
55
62
  def wildcard_match(actual)
56
- unless actual.is_a?(Array)
63
+ unless actual and actual.is_a?(Array)
57
64
  errors << "#{position}: expect #{actual.inspect} to #{expectation.inspect}"
58
65
  return
59
66
  end
@@ -72,7 +79,7 @@ module WildcardMatchers
72
79
  class HashMatcher < WildcardMatcher
73
80
  protected
74
81
  def wildcard_match(actual)
75
- unless actual.is_a?(Hash)
82
+ unless actual and actual.is_a?(Hash)
76
83
  errors << "#{position}: expect #{actual.inspect} to #{expectation.inspect}"
77
84
  return
78
85
  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.1.2
4
+ version: 0.1.3
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-11-06 00:00:00.000000000 Z
12
+ date: 2013-02-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: facets