json_matchers 0.7.1 → 0.7.2
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/NEWS.md +7 -0
- data/lib/json_matchers/payload.rb +2 -2
- data/lib/json_matchers/version.rb +1 -1
- data/spec/json_matchers/match_response_schema_spec.rb +39 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 55bb76610a71379a9b0644723605a728b25da73e
|
4
|
+
data.tar.gz: 478ee6d652882830ffd6f09f88c7499163732c16
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 65f5fc41b21b2d858f7f7230d16ed537413868e684df40a46aed5d091706e238e64230449ae37ab0ec43b89fa10bee0416c7c634ae19d4316647727e314ed5a1
|
7
|
+
data.tar.gz: 1c447958803f30f2290d51287ba0386fc5ae4fe77b7646b090a1dce028058b3795404a36ffb86dc4635d2b5717830a3d62e62be1758b9b5251af42e5862abc2f
|
data/NEWS.md
CHANGED
@@ -15,8 +15,8 @@ module JsonMatchers
|
|
15
15
|
def extract_json_string(payload)
|
16
16
|
if payload.respond_to?(:body)
|
17
17
|
payload.body
|
18
|
-
elsif payload.
|
19
|
-
payload.
|
18
|
+
elsif payload.is_a?(Array) || payload.is_a?(Hash)
|
19
|
+
payload.to_json
|
20
20
|
else
|
21
21
|
payload
|
22
22
|
end
|
@@ -56,6 +56,45 @@ describe JsonMatchers, "#match_response_schema" do
|
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
59
|
+
context "when passed a Array" do
|
60
|
+
it "validates when the schema matches" do
|
61
|
+
create_schema("foo_schema", {
|
62
|
+
"type" => "array",
|
63
|
+
"items" => {
|
64
|
+
"required" => [
|
65
|
+
"id",
|
66
|
+
],
|
67
|
+
"properties" => {
|
68
|
+
"id" => { "type" => "number" },
|
69
|
+
},
|
70
|
+
"additionalProperties" => false,
|
71
|
+
}
|
72
|
+
})
|
73
|
+
|
74
|
+
expect([{ "id" => 1 }]).to match_response_schema("foo_schema")
|
75
|
+
end
|
76
|
+
|
77
|
+
it "fails with message when negated" do
|
78
|
+
create_schema("foo_schema", {
|
79
|
+
"type" => "array",
|
80
|
+
"items" => {
|
81
|
+
"type" => "object",
|
82
|
+
"required" => [
|
83
|
+
"id",
|
84
|
+
],
|
85
|
+
"properties" => {
|
86
|
+
"id" => { "type" => "number" },
|
87
|
+
},
|
88
|
+
"additionalProperties" => false,
|
89
|
+
}
|
90
|
+
})
|
91
|
+
|
92
|
+
expect {
|
93
|
+
expect([{ "id" => "1" }]).to match_response_schema("foo_schema")
|
94
|
+
}.to raise_formatted_error(%{{ "type": "number" }})
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
59
98
|
context "when JSON is a string" do
|
60
99
|
before(:each) do
|
61
100
|
create_schema("foo_schema", {
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: json_matchers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sean Doyle
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-10-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json-schema
|