hash_dealer 1.1.3 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.3
1
+ 1.2.0
data/hash_dealer.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{hash_dealer}
8
- s.version = "1.1.3"
8
+ s.version = "1.2.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Dan Langevin"]
data/lib/matcher.rb CHANGED
@@ -18,12 +18,16 @@ RSpec::Matchers.define(:match_response) do |actual|
18
18
  end
19
19
 
20
20
  # alias as match_json
21
- RSpec::Matchers.define(:match_json) do |actual|
21
+ RSpec::Matchers.define(:match_list) do |actual|
22
22
 
23
23
  match do |expected|
24
+ actual = JSON.parse(actual) if actual.is_a?(String)
25
+ expected = JSON.parse(expected) if expected.is_a?(String)
26
+ actual = actual.first if actual.is_a?(Array)
27
+ expected = expected.first if expected.is_a?(Array)
24
28
  PathString.as_sorted_json(actual) == PathString.as_sorted_json(expected)
25
29
  end
26
-
30
+
27
31
  failure_message_for_should do |container|
28
32
  "expected #{PathString.as_sorted_json(actual)}\n to equal\n #{PathString.as_sorted_json(container)}"
29
33
  end
@@ -10,4 +10,8 @@ describe "match_resonse Matcher" do
10
10
  {:a => {:b => "/test/test"}}.should match_response({"a" =>{"b" => "/:a/:b"}})
11
11
  end
12
12
 
13
+ it "should match the first element in a list" do
14
+ {"a" => ":b"}.should match_list([{"a" => "test"}, {"a" => "test2"}])
15
+ end
16
+
13
17
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: hash_dealer
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.1.3
5
+ version: 1.2.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - Dan Langevin
@@ -129,7 +129,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
129
129
  requirements:
130
130
  - - ">="
131
131
  - !ruby/object:Gem::Version
132
- hash: 531561907666267100
132
+ hash: 4171646845594495161
133
133
  segments:
134
134
  - 0
135
135
  version: "0"