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 ADDED
@@ -0,0 +1,4 @@
1
+ rvm:
2
+ - 1.9.2
3
+ - 1.9.3
4
+ - ruby-head
data/CHANGELOG.md ADDED
@@ -0,0 +1,6 @@
1
+ ## 0.0.2
2
+ * BUGFIX
3
+ * bug fix comparing Hash with Array
4
+
5
+ ## 0.0.1
6
+ * first release
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # 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)
2
2
 
3
3
  ## General Usage
4
4
 
data/Rakefile CHANGED
@@ -1,2 +1,10 @@
1
1
  #!/usr/bin/env rake
2
2
  require "bundler/gem_tasks"
3
+
4
+ require 'rspec/core'
5
+ require 'rspec/core/rake_task'
6
+ RSpec::Core::RakeTask.new(:spec) do |spec|
7
+ spec.pattern = FileList['spec/**/*_spec.rb']
8
+ end
9
+
10
+ task :default => :spec
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1
1
+ 0.0.2
@@ -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.1
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 00:00:00.000000000 Z
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