json_spec 1.1.3 → 1.1.4
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 +4 -4
- data/json_spec.gemspec +1 -1
- data/lib/json_spec/errors.rb +12 -0
- data/lib/json_spec/matchers/have_json_size.rb +2 -1
- data/spec/json_spec/matchers/have_json_size_spec.rb +12 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1f89c2ff2fad3cd8fc443551ea7d118d7ae865ed
|
4
|
+
data.tar.gz: 999fffbcd5db02290e7bd36762bee3c7e3e50c69
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aa4a0d179b15d62a16e11e16fbabda7dd642e7015903964b17c51846e21273f4904555e641c20ffade46301bc1e5277cd96df2efb2c7e74c38d31e78c39ca245
|
7
|
+
data.tar.gz: 6b7f34cd9a5b8f326976e6335c64b93f63cd0d0fb0d204e04606013e3e6d1b8fae055f889543ba50ce08fb77cf07373c090f6d9deb0252b5b1c76bedee4fb2f6
|
data/json_spec.gemspec
CHANGED
data/lib/json_spec/errors.rb
CHANGED
@@ -31,4 +31,16 @@ module JsonSpec
|
|
31
31
|
"No JSON file at #{path}"
|
32
32
|
end
|
33
33
|
end
|
34
|
+
|
35
|
+
class EnumerableExpected < Error
|
36
|
+
attr_reader :actual_value
|
37
|
+
|
38
|
+
def initialize(actual_value)
|
39
|
+
@actual_value = actual_value
|
40
|
+
end
|
41
|
+
|
42
|
+
def to_s
|
43
|
+
"Enumerable expected, got #{actual_value.inspect}"
|
44
|
+
end
|
45
|
+
end
|
34
46
|
end
|
@@ -46,4 +46,16 @@ describe JsonSpec::Matchers::HaveJsonSize do
|
|
46
46
|
matcher.matches?(%({"id":1,"json":["spec"]}))
|
47
47
|
matcher.description.should == %(have JSON size "1" at path "json")
|
48
48
|
end
|
49
|
+
|
50
|
+
it "provides an error when parsing nil" do
|
51
|
+
matcher = have_json_size(0).at_path("json")
|
52
|
+
expect { matcher.matches?(%({"id":1,"json":null})) }.to raise_error(JsonSpec::EnumerableExpected,
|
53
|
+
"Enumerable expected, got nil")
|
54
|
+
end
|
55
|
+
|
56
|
+
it "provides an error when parsing non-enumerables" do
|
57
|
+
matcher = have_json_size(0).at_path("json")
|
58
|
+
expect { matcher.matches?(%({"id":1,"json":12345})) }.to raise_error(JsonSpec::EnumerableExpected,
|
59
|
+
"Enumerable expected, got 12345")
|
60
|
+
end
|
49
61
|
end
|