hash_dealer 1.2.0 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.2.0
1
+ 1.2.1
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.2.0"
8
+ s.version = "1.2.1"
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"]
@@ -8,7 +8,8 @@ end
8
8
  # The only really important matcher
9
9
  class String
10
10
  def matcher(opts = {})
11
- ":#{self}"
11
+ # if we have a leading : or a /:xyz - a matcher is already defined
12
+ self =~ /(^:|\/:)/ ? self : ":#{self}"
12
13
  end
13
14
  end
14
15
 
data/lib/matcher.rb CHANGED
@@ -20,20 +20,22 @@ end
20
20
  # alias as match_json
21
21
  RSpec::Matchers.define(:match_list) do |actual|
22
22
 
23
+ def normalize(val)
24
+ val = JSON.parse(val) if val.is_a?(String)
25
+ val = val.first if val.is_a?(Array)
26
+ val
27
+ end
28
+
23
29
  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)
28
- PathString.as_sorted_json(actual) == PathString.as_sorted_json(expected)
30
+ PathString.as_sorted_json(normalize(actual)) == PathString.as_sorted_json(normalize(expected))
29
31
  end
30
32
 
31
33
  failure_message_for_should do |container|
32
- "expected #{PathString.as_sorted_json(actual)}\n to equal\n #{PathString.as_sorted_json(container)}"
34
+ "expected #{PathString.as_sorted_json(normalize(actual))}\n to equal\n #{PathString.as_sorted_json(normalize(container))}"
33
35
  end
34
36
 
35
37
  failure_message_for_should_not do |container|
36
- "expected #{PathString.as_sorted_json(actual)}\n not to equal\n #{PathString.as_sorted_json(container)}"
38
+ "expected #{PathString.as_sorted_json(normalize(actual))}\n not to equal\n #{PathString.as_sorted_json(normalize(container))}"
37
39
  end
38
40
 
39
41
  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.2.0
5
+ version: 1.2.1
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: 4171646845594495161
132
+ hash: 3813093345563584248
133
133
  segments:
134
134
  - 0
135
135
  version: "0"