hash_dealer 1.4.6 → 1.4.7
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/hash_dealer.gemspec +2 -2
- data/lib/comparator.rb +6 -6
- data/lib/matcher.rb +1 -1
- data/spec/lib/matcher_spec.rb +3 -3
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.4.
|
1
|
+
1.4.7
|
data/hash_dealer.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "hash_dealer"
|
8
|
-
s.version = "1.4.
|
8
|
+
s.version = "1.4.7"
|
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"]
|
12
|
-
s.date = "2011-
|
12
|
+
s.date = "2011-12-14"
|
13
13
|
s.description = "Like Factory Girl but for Hashes only"
|
14
14
|
s.email = "dan.langevin@lifebooker.com"
|
15
15
|
s.extra_rdoc_files = [
|
data/lib/comparator.rb
CHANGED
@@ -28,12 +28,12 @@ class Comparator
|
|
28
28
|
def self.hash_diff(obj1, obj2)
|
29
29
|
obj1, obj2 = self.stringify_keys(obj1), self.stringify_keys(obj2)
|
30
30
|
(obj1.keys + obj2.keys).uniq.inject({}) do |memo, key|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
31
|
+
if !obj1.keys.include?(key)
|
32
|
+
memo[key] = ["KEY MISSING", obj2[key]]
|
33
|
+
elsif !obj2.keys.include?(key)
|
34
|
+
memo[key] = [obj1[key], "KEY MISSING"]
|
35
|
+
elsif obj1[key] != obj2[key]
|
36
|
+
memo[key] = self.diff(obj1[key], obj2[key])
|
37
37
|
end
|
38
38
|
memo
|
39
39
|
end
|
data/lib/matcher.rb
CHANGED
@@ -4,7 +4,7 @@ require 'pp'
|
|
4
4
|
|
5
5
|
|
6
6
|
def print_diff(diff, depth = 1)
|
7
|
-
puts "#{"\t" * depth}" + "HashDealer::#{diff.first.to_s}".bold.cyan + "\tResponse::#{diff.last.to_s}".bold.yellow if diff.is_a?(Array)
|
7
|
+
puts "#{"\t" * depth}" + "HashDealer::#{diff.first.to_s}".bold.cyan + "\t\t\t\tResponse::#{diff.last.to_s}".bold.yellow if diff.is_a?(Array)
|
8
8
|
if diff.is_a?(Hash)
|
9
9
|
diff.each_pair do |k, v|
|
10
10
|
puts "\n"
|
data/spec/lib/matcher_spec.rb
CHANGED
@@ -32,7 +32,7 @@ describe "match_response Matcher" do
|
|
32
32
|
|
33
33
|
it "should provide meaningful diffs" do
|
34
34
|
diff = Comparator.diff({:a => {:b => "c", :d => "e"}}, {:a => {:b => "d", :d => "e"}, :b => "test"})
|
35
|
-
diff.should eql({"a" => {"b" => ["c", "d"]}, "b" => [
|
35
|
+
diff.should eql({"a" => {"b" => ["c", "d"]}, "b" => ["KEY MISSING", "test"]})
|
36
36
|
end
|
37
37
|
|
38
38
|
it "should match hashes regardless of the order of the keys" do
|
@@ -54,8 +54,8 @@ describe "match_response Matcher" do
|
|
54
54
|
end
|
55
55
|
|
56
56
|
it "should return a diff when either argument is missing a key" do
|
57
|
-
Comparator.diff({"a" => true, "b" => false}, {"a" => true}).should eql({"b" => [false,
|
58
|
-
Comparator.diff({"a" => true}, {"a" => true, "b" => false}).should eql({"b" => [
|
57
|
+
Comparator.diff({"a" => true, "b" => false}, {"a" => true}).should eql({"b" => [false, "KEY MISSING"]})
|
58
|
+
Comparator.diff({"a" => true}, {"a" => true, "b" => false}).should eql({"b" => ["KEY MISSING", false]})
|
59
59
|
end
|
60
60
|
|
61
61
|
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.4.
|
5
|
+
version: 1.4.7
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Dan Langevin
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-
|
13
|
+
date: 2011-12-14 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activesupport
|
@@ -165,7 +165,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
165
165
|
requirements:
|
166
166
|
- - ">="
|
167
167
|
- !ruby/object:Gem::Version
|
168
|
-
hash:
|
168
|
+
hash: 3422105148063784336
|
169
169
|
segments:
|
170
170
|
- 0
|
171
171
|
version: "0"
|