json_matchers 0.4.0 → 0.5.0
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 +56 -5
- data/README.md +12 -8
- data/lib/json_matchers/matcher.rb +1 -5
- data/lib/json_matchers/version.rb +1 -1
- metadata +3 -4
- data/CHANGELOG.md +0 -34
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ae47ba6e026a29f0f498146f78039dd5b65f75cb
|
4
|
+
data.tar.gz: e8d728527e3010c55cdd2019376bfb2c61aa2352
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bbb54160e7035e4cfe4d2ae9741604fc157166f85ff431b62fdc92240cd850ae6a82b2da4fed61d9936b8a9ad65c241319f50b86f8e2f7f38ea8c0974198f559
|
7
|
+
data.tar.gz: 64c775526e26c009d99660e98ef7f3fbf38b0ef0cc2087d4104a48feef1edc215a8261fdf7d619ea07795da76bff5ff1071ae829ddfbb56e2f48f396652e12a2
|
data/NEWS.md
CHANGED
@@ -1,17 +1,68 @@
|
|
1
|
-
|
1
|
+
master
|
2
|
+
======
|
3
|
+
|
4
|
+
Breaking Changes
|
5
|
+
----------------
|
6
|
+
|
7
|
+
* No longer default to `strict: true`.
|
8
|
+
|
9
|
+
0.4.0
|
10
|
+
=====
|
11
|
+
|
12
|
+
Breaking Changes
|
13
|
+
----------------
|
14
|
+
|
15
|
+
* Rename the gem to `json_matchers`.
|
16
|
+
|
17
|
+
0.3.1
|
18
|
+
=====
|
19
|
+
|
20
|
+
* No longer condone auto-loading RSpec. Add documentation around adding `require
|
21
|
+
"json_matchers/rspec"` to consumers' `spec/spec_helper.rb`
|
22
|
+
|
23
|
+
Breaking Changes
|
24
|
+
----------------
|
25
|
+
|
26
|
+
* Rename module to `JsonMatchers`. This resolves clashing with
|
27
|
+
gems like `oj` / `oj_mimic_json` that take control of the standard library's
|
28
|
+
`json` module. As a result, the file to require is now `json_matchers`,
|
29
|
+
instead of `json/matchers`.
|
30
|
+
|
31
|
+
0.3.0
|
32
|
+
=====
|
33
|
+
|
34
|
+
* Pass options from matcher to `JSON::Validator`
|
35
|
+
|
36
|
+
0.2.2
|
37
|
+
=====
|
38
|
+
|
39
|
+
* Includes validation failure message in RSpec output
|
40
|
+
|
41
|
+
0.2.1
|
42
|
+
=====
|
43
|
+
|
44
|
+
* Supports RSpec 2 syntax `failure_message_for_should` and
|
45
|
+
`failure_message_for_should_not`
|
46
|
+
|
47
|
+
0.2.0
|
48
|
+
=====
|
2
49
|
|
3
50
|
* RSpec failure messages include both the body of the response, and the body of
|
4
51
|
the JSON Schema file
|
5
52
|
|
6
|
-
|
53
|
+
0.1.0
|
54
|
+
=====
|
7
55
|
|
8
|
-
|
56
|
+
Breaking Changes
|
57
|
+
----------------
|
9
58
|
|
10
59
|
* Remove `schema_for` in favor of using `$ref`. To learn more about `$ref`,
|
11
60
|
check out [Understanding JSON Schema Structuring](http://spacetelescope.github.io/understanding-json-schema/structuring.html)
|
12
61
|
|
13
|
-
|
62
|
+
0.0.1
|
63
|
+
=====
|
14
64
|
|
15
|
-
|
65
|
+
Features
|
66
|
+
--------
|
16
67
|
|
17
68
|
* Validate your Rails response JSON with `match_response_schema`
|
data/README.md
CHANGED
@@ -41,12 +41,16 @@ Define your [JSON Schema](http://json-schema.org/example1.html) in the schema di
|
|
41
41
|
"type": "object",
|
42
42
|
"required": ["posts"],
|
43
43
|
"properties": {
|
44
|
-
"
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
44
|
+
"posts": {
|
45
|
+
"type": "array",
|
46
|
+
"items":{
|
47
|
+
"required": ["id", "title", "body"],
|
48
|
+
"properties": {
|
49
|
+
"id": { "type": "integer" },
|
50
|
+
"title": { "type": "string" },
|
51
|
+
"body": { "type": "string" }
|
52
|
+
}
|
53
|
+
}
|
50
54
|
}
|
51
55
|
}
|
52
56
|
}
|
@@ -69,7 +73,7 @@ end
|
|
69
73
|
|
70
74
|
### Passing options to the validator
|
71
75
|
|
72
|
-
The matcher accepts options, which it
|
76
|
+
The matcher accepts options, which it passes to the validator:
|
73
77
|
|
74
78
|
```ruby
|
75
79
|
# spec/requests/posts_spec.rb
|
@@ -79,7 +83,7 @@ describe "GET /posts" do
|
|
79
83
|
get posts_path, format: :json
|
80
84
|
|
81
85
|
expect(response.status).to eq 200
|
82
|
-
expect(response).to match_response_schema("posts", strict:
|
86
|
+
expect(response).to match_response_schema("posts", strict: true)
|
83
87
|
end
|
84
88
|
end
|
85
89
|
```
|
@@ -10,14 +10,10 @@ module JsonMatchers
|
|
10
10
|
def matches?(response)
|
11
11
|
@response = response
|
12
12
|
|
13
|
-
validator_options = {
|
14
|
-
strict: true,
|
15
|
-
}.merge(options)
|
16
|
-
|
17
13
|
JSON::Validator.validate!(
|
18
14
|
schema_path.to_s,
|
19
15
|
response.body,
|
20
|
-
|
16
|
+
options,
|
21
17
|
)
|
22
18
|
rescue JSON::Schema::ValidationError => ex
|
23
19
|
@validation_failure_message = ex.message
|
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.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sean Doyle
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-11-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json-schema
|
@@ -104,7 +104,6 @@ files:
|
|
104
104
|
- ".gitignore"
|
105
105
|
- ".rspec"
|
106
106
|
- ".travis.yml"
|
107
|
-
- CHANGELOG.md
|
108
107
|
- CONTRIBUTING.md
|
109
108
|
- Gemfile
|
110
109
|
- LICENSE.txt
|
@@ -140,7 +139,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
140
139
|
version: '0'
|
141
140
|
requirements: []
|
142
141
|
rubyforge_project:
|
143
|
-
rubygems_version: 2.
|
142
|
+
rubygems_version: 2.5.0
|
144
143
|
signing_key:
|
145
144
|
specification_version: 4
|
146
145
|
summary: Validate your Rails JSON API's JSON
|
data/CHANGELOG.md
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
master
|
2
|
-
------
|
3
|
-
|
4
|
-
0.4.0
|
5
|
-
-----
|
6
|
-
|
7
|
-
* BREAKING CHANGE: Rename the gem to `json_matchers`.
|
8
|
-
|
9
|
-
0.3.1
|
10
|
-
-----
|
11
|
-
|
12
|
-
* BREAKING CHANGE: Rename module to `JsonMatchers`. This resolves clashing with
|
13
|
-
gems like `oj` / `oj_mimic_json` that take control of the standard library's
|
14
|
-
`json` module. As a result, the file to require is now `json_matchers`,
|
15
|
-
instead of `json/matchers`.
|
16
|
-
|
17
|
-
* No longer condone auto-loading RSpec. Add documentation around adding `require
|
18
|
-
"json_matchers/rspec"` to consumers' `spec/spec_helper.rb`
|
19
|
-
|
20
|
-
0.3.0
|
21
|
-
-----
|
22
|
-
|
23
|
-
* Pass options from matcher to `JSON::Validator`
|
24
|
-
|
25
|
-
0.2.2
|
26
|
-
-----
|
27
|
-
|
28
|
-
* Includes validation failure message in RSpec output
|
29
|
-
|
30
|
-
0.2.1
|
31
|
-
-----
|
32
|
-
|
33
|
-
* Supports RSpec 2 syntax `failure_message_for_should` and
|
34
|
-
`failure_message_for_should_not`
|