hash_police 0.0.2 → 0.0.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2cb08c7624e26e2f6dd120205fc763775529cb97
4
- data.tar.gz: 1ab033f86e8b6a75057b604ee8adfc4be7642bef
3
+ metadata.gz: ad058f96fd412a77400f8cf0a3d034394bd7cd88
4
+ data.tar.gz: 5d09df0ade02fc80b6b52706e59a26c22a013b0f
5
5
  SHA512:
6
- metadata.gz: 7cc7106d520b66cbc5652bbe1951b8df2dd9d516835f0f7abedf4a2f1a91020a4d84406b49c788873fb597d333a668716a4b1d8fc142e17281eb1cd072d4b61b
7
- data.tar.gz: c5e41ea33a01c90740cb0115435511ce549e68aa34a83c31b90eb41ec995cb10b88099cd98f552052b1af368ff955a7930ffa48c3957cb23e3aa91538df05862
6
+ metadata.gz: 030915243afc73a524f67166afbb1d5f440cd8cd1e539a1b37d30f541fb9bb038f4ed4ec0954beb00e18be6133a61217a2143c38a3e126ec5c40251f8b8209ae
7
+ data.tar.gz: 3687760e41798d3e768503a1432eacdc7887bd2654971bc737cf18991e39c1848b9040175d0f628fb8797c69566f2c2bce7def80162ae219fb95a23951605ba7
@@ -12,7 +12,7 @@ class HashPolice::CheckResult
12
12
  end
13
13
 
14
14
  def error_messages
15
- all_errors.join("; ")
15
+ all_errors.join("\n")
16
16
  end
17
17
 
18
18
  def all_errors
@@ -25,8 +25,9 @@ class HashPolice::CheckResult
25
25
  @children << child_result
26
26
  end
27
27
 
28
- def missing
29
- @errors << "`#{context_key}`: missing"
28
+ def missing key = nil
29
+ error_key = key || context_key
30
+ @errors << "`#{error_key}`: missing"
30
31
  end
31
32
 
32
33
  def passed?
@@ -1,3 +1,3 @@
1
1
  module HashPolice
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -29,18 +29,24 @@ describe HashPolice::CheckResult do
29
29
  children[1].differ_type(:expect => String, :got => Fixnum)
30
30
  children[2].missing
31
31
 
32
- result.error_messages.should == "`key-2`: expect String, got Fixnum; `key-3`: missing"
32
+ result.error_messages.should == "`key-2`: expect String, got Fixnum\n`key-3`: missing"
33
33
  end
34
34
  end
35
35
 
36
36
  end
37
37
 
38
- describe "#missing" do
38
+ describe "#missing(key = nil)" do
39
39
  it "adds missing message to errors" do
40
40
  result.missing
41
41
 
42
42
  result.error_messages.should == "`#{context_key}`: missing"
43
43
  end
44
+
45
+ it "assigns missing key if given" do
46
+ result.missing("the-key")
47
+
48
+ result.error_messages.should == "`the-key`: missing"
49
+ end
44
50
  end
45
51
 
46
52
  describe "#differ_type(:expect => Class1, :got => Class2)" do
@@ -109,6 +109,13 @@ describe HashPolice::Police do
109
109
 
110
110
  police.check(target)
111
111
  end
112
+
113
+ it "failed if nested key missing" do
114
+ target[:nested] = {}
115
+ result_nested.should_receive(:missing).with("nested.key")
116
+
117
+ police.check(target)
118
+ end
112
119
  end
113
120
  end
114
121
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hash_police
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yang-Hsing Lin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-13 00:00:00.000000000 Z
11
+ date: 2014-01-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler