rspec-matchers-adhere_to_schema 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE.md +20 -0
- data/README.md +126 -0
- data/lib/rspec/matchers/adhere_to_schema.rb +123 -0
- data/lib/rspec/matchers/adhere_to_schema/identity.rb +24 -0
- data/lib/tasks/rspec.rake +6 -0
- data/lib/tasks/rubocop.rake +6 -0
- data/vendor/jsonapi.schema +370 -0
- metadata +294 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 5314dc649f47d5e615edb0c1556f917ccf6c1190
|
4
|
+
data.tar.gz: c16504f267514f6758683d1ef4db4203a3ae8e52
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5a7bb6bfdcfcf6865a361751b2fce73afbe11a6612f905ab1edb34b0b78ce1e7adc8d796060b35fe089285a3f2dd9c165213ab9f90f63500f49b06f0a7adac2e
|
7
|
+
data.tar.gz: 65011201cf67a54e9e0fb2013ab0bb5e90202a7605af8a43b846b60df2b06368544a5bc2e777f492b01e514c90fc1034a691ac9fd102ec4b460d4e6331ff8622
|
data/LICENSE.md
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2016 [Pooyan Khosravi]().
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,126 @@
|
|
1
|
+
# RSpec Matcher `adhere_to_schema`
|
2
|
+
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/rspec_matcher_match_schema.svg)](http://badge.fury.io/rb/rspec_matcher_match_schema)
|
4
|
+
[![Code Climate GPA](https://codeclimate.com/github//rspec_matcher_match_schema.svg)](https://codeclimate.com/github/pekhee/rspec_matcher_match_schema)
|
5
|
+
[![Code Climate Coverage](https://codeclimate.com/github//rspec_matcher_match_schema/coverage.svg)](https://codeclimate.com/github/pekhee/rspec_matcher_match_schema)
|
6
|
+
[![Gemnasium Status](https://gemnasium.com//rspec_matcher_match_schema.svg)](https://gemnasium.com/pekhee/rspec_matcher_match_schema)
|
7
|
+
[![Travis CI Status](https://secure.travis-ci.org//rspec_matcher_match_schema.svg)](https://travis-ci.org/pekhee/rspec_matcher_match_schema)
|
8
|
+
|
9
|
+
<!-- Tocer[start]: Auto-generated, don't remove. -->
|
10
|
+
|
11
|
+
# Table of Contents
|
12
|
+
|
13
|
+
- [Features](#features)
|
14
|
+
- [Requirements](#requirements)
|
15
|
+
- [Setup](#setup)
|
16
|
+
- [Usage](#usage)
|
17
|
+
- [Tests](#tests)
|
18
|
+
- [Versioning](#versioning)
|
19
|
+
- [Code of Conduct](#code-of-conduct)
|
20
|
+
- [Contributions](#contributions)
|
21
|
+
- [License](#license)
|
22
|
+
- [History](#history)
|
23
|
+
- [Credits](#credits)
|
24
|
+
|
25
|
+
<!-- Tocer[finish]: Auto-generated, don't remove. -->
|
26
|
+
|
27
|
+
# Features
|
28
|
+
|
29
|
+
- Test if some data adheres to specified json schema
|
30
|
+
- Define json schema in a schemas directory and they will be automatically
|
31
|
+
picked
|
32
|
+
|
33
|
+
# Requirements
|
34
|
+
|
35
|
+
0. [MRI 2.2.3](https://www.ruby-lang.org)
|
36
|
+
1. [RSpec 3.x](http://rspec.info)
|
37
|
+
|
38
|
+
# Setup
|
39
|
+
|
40
|
+
To install, type the following:
|
41
|
+
|
42
|
+
gem install rspec-matchers-adhere_to_schema
|
43
|
+
|
44
|
+
Add the following to your Gemfile:
|
45
|
+
|
46
|
+
gem "rspec-matchers-adhere_to_schema"
|
47
|
+
|
48
|
+
This gem is signed. Use pekhee.pem as public key.
|
49
|
+
|
50
|
+
# Usage
|
51
|
+
|
52
|
+
RSpec.describe "a user document" do
|
53
|
+
subject do
|
54
|
+
JSON.parse <<-JSON_DOC
|
55
|
+
{
|
56
|
+
firstName: "Pooyan",
|
57
|
+
lastName: "Khosravi"
|
58
|
+
}
|
59
|
+
JSON_DOC
|
60
|
+
end
|
61
|
+
|
62
|
+
let :user_schema do
|
63
|
+
JSON.parse <<-JSON_SCHEMA
|
64
|
+
{
|
65
|
+
"title": "User Schema",
|
66
|
+
"type": "object",
|
67
|
+
"properties": {
|
68
|
+
"firstName": {
|
69
|
+
"type": "string"
|
70
|
+
},
|
71
|
+
"lastName": {
|
72
|
+
"type": "string"
|
73
|
+
},
|
74
|
+
"age": {
|
75
|
+
"description": "Age in years",
|
76
|
+
"type": "integer",
|
77
|
+
"minimum": 0
|
78
|
+
}
|
79
|
+
},
|
80
|
+
"required": ["firstName", "lastName"]
|
81
|
+
}
|
82
|
+
JSON_SCHEMA
|
83
|
+
end
|
84
|
+
|
85
|
+
it "adheres to user schema" do
|
86
|
+
expect(subject).to match_schema user_schema
|
87
|
+
expect(subject).to matche_schema :user # spec/schemas/user.json
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
# Tests
|
92
|
+
|
93
|
+
To test, run:
|
94
|
+
|
95
|
+
bundle exec rake
|
96
|
+
|
97
|
+
# Versioning
|
98
|
+
|
99
|
+
Read [Semantic Versioning](http://semver.org) for details. Briefly, it means:
|
100
|
+
|
101
|
+
- Patch (x.y.Z) - Incremented for small, backwards compatible bug fixes.
|
102
|
+
- Minor (x.Y.z) - Incremented for new, backwards compatible public API enhancements and/or bug fixes.
|
103
|
+
- Major (X.y.z) - Incremented for any backwards incompatible public API changes.
|
104
|
+
|
105
|
+
# Code of Conduct
|
106
|
+
|
107
|
+
Please note that this project is released with a [CODE OF CONDUCT](CODE_OF_CONDUCT.md). By participating in this project
|
108
|
+
you agree to abide by its terms.
|
109
|
+
|
110
|
+
# Contributions
|
111
|
+
|
112
|
+
Read [CONTRIBUTING](CONTRIBUTING.md) for details.
|
113
|
+
|
114
|
+
# License
|
115
|
+
|
116
|
+
Copyright (c) 2016 [Pooyan Khosravi]().
|
117
|
+
Read the [LICENSE](LICENSE.md) for details.
|
118
|
+
|
119
|
+
# History
|
120
|
+
|
121
|
+
Read the [CHANGELOG](CHANGELOG.md) for details.
|
122
|
+
Built with [Gemsmith](https://github.com/bkuhlmann/gemsmith).
|
123
|
+
|
124
|
+
# Credits
|
125
|
+
|
126
|
+
Developed by [Pooyan Khosravi]().
|
@@ -0,0 +1,123 @@
|
|
1
|
+
require "rspec/matchers/adhere_to_schema/identity"
|
2
|
+
require "pathname"
|
3
|
+
require "rspec/matcher"
|
4
|
+
require "json-schema"
|
5
|
+
|
6
|
+
module RSpec
|
7
|
+
module Matchers
|
8
|
+
# Check if given data matches a json schema.
|
9
|
+
#
|
10
|
+
# Includes jsonapi.org schema, supports passing objects as schemas or
|
11
|
+
# schema files under spec/schemas/NAME.json.
|
12
|
+
#
|
13
|
+
# @example
|
14
|
+
# it "is jsonapi compatible and follows article schema" do
|
15
|
+
# expect(data).to adhere_to_schema(:article_schema).and_jsonapi
|
16
|
+
# end
|
17
|
+
# @note You can use adhere_to_jsonapi to just make sure data follows
|
18
|
+
# jsonapi.
|
19
|
+
class AdhereToSchema
|
20
|
+
include RSpec::Matcher
|
21
|
+
JSONAPI = Pathname.new(__FILE__).join("..", "..", "..", "..", "vendor", "jsonapi.schema").to_s
|
22
|
+
|
23
|
+
register_as :adhere_to_schema
|
24
|
+
register_as :adhere_to_jsonapi, jsonapi: true
|
25
|
+
attr_accessor :jsonapi, :errors
|
26
|
+
|
27
|
+
# @method jsonapi
|
28
|
+
# @api private
|
29
|
+
# @return [Boolean]
|
30
|
+
|
31
|
+
# @method errors
|
32
|
+
# @api private
|
33
|
+
# @return [Array]
|
34
|
+
|
35
|
+
# Defines schemas dir, Feel free to replace with another string.
|
36
|
+
# @return [String]
|
37
|
+
def self.schema_dir
|
38
|
+
File.expand_path(File.join(RSpec.configuration.default_path, "schemas"))
|
39
|
+
end
|
40
|
+
|
41
|
+
# @api private
|
42
|
+
# @note Errors are created on the fly in an append only style
|
43
|
+
def initialize
|
44
|
+
self.errors = []
|
45
|
+
end
|
46
|
+
|
47
|
+
# @api private
|
48
|
+
# Main logic
|
49
|
+
# @note uses throw as control flow
|
50
|
+
def match
|
51
|
+
validate_input
|
52
|
+
validate_with_schema schema if schema?
|
53
|
+
validate_with_schema JSONAPI if jsonapi?
|
54
|
+
|
55
|
+
true
|
56
|
+
end
|
57
|
+
|
58
|
+
# @api private
|
59
|
+
def failure_message
|
60
|
+
<<-MSG.gsub(/^\s+/, " ")
|
61
|
+
expected data to match against #{schema_name} schema but data had following errors.
|
62
|
+
errors:
|
63
|
+
#{errors}
|
64
|
+
----
|
65
|
+
data:
|
66
|
+
#{data}
|
67
|
+
MSG
|
68
|
+
end
|
69
|
+
|
70
|
+
# @api private
|
71
|
+
def failure_message_when_negated
|
72
|
+
"expected data to not match #{schema_name} but it did."
|
73
|
+
end
|
74
|
+
|
75
|
+
# Indicates that matcher should try to match agains jsonapi too
|
76
|
+
# @return [self]
|
77
|
+
def and_jsonapi
|
78
|
+
self.jsonapi = true
|
79
|
+
|
80
|
+
self
|
81
|
+
end
|
82
|
+
|
83
|
+
private
|
84
|
+
|
85
|
+
alias_method :schema_name, :expected
|
86
|
+
alias_method :data, :actual
|
87
|
+
|
88
|
+
def schema
|
89
|
+
return schema_name if schema_name.is_a? Hash
|
90
|
+
File.join self.class.schema_dir, "#{schema_name}.json"
|
91
|
+
end
|
92
|
+
|
93
|
+
def schema?
|
94
|
+
!undefined?
|
95
|
+
end
|
96
|
+
|
97
|
+
def jsonapi?
|
98
|
+
jsonapi == true
|
99
|
+
end
|
100
|
+
|
101
|
+
def valid_schema?
|
102
|
+
return true if undefined?
|
103
|
+
|
104
|
+
schema.is_a?(Hash) || File.exist?(schema)
|
105
|
+
end
|
106
|
+
|
107
|
+
# @api private
|
108
|
+
# @note Throws
|
109
|
+
def validate_input
|
110
|
+
raise "#{schema} does not exist" unless valid_schema?
|
111
|
+
resolve_expectation if data.nil? || data == "" # There is no data to validate
|
112
|
+
end
|
113
|
+
|
114
|
+
# @api private
|
115
|
+
# @note Throws
|
116
|
+
def validate_with_schema file
|
117
|
+
return true if JSON::Validator.validate(file, data)
|
118
|
+
self.errors += JSON::Validator.fully_validate(file, data)
|
119
|
+
reject_expectation
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module RSpec
|
2
|
+
module Matchers
|
3
|
+
class AdhereToSchema
|
4
|
+
# Gem identity information.
|
5
|
+
module Identity
|
6
|
+
def self.name
|
7
|
+
"rspec-matchers-adhere_to_schema"
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.label
|
11
|
+
"RSpec::Matchers::AdhereToSchema"
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.version
|
15
|
+
"0.1.0"
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.version_label
|
19
|
+
"#{label} #{version}"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,370 @@
|
|
1
|
+
{
|
2
|
+
"$schema": "http://json-schema.org/draft-04/schema#",
|
3
|
+
"title": "JSON API Schema",
|
4
|
+
"description": "This is a schema for responses in the JSON API format. For more, see http://jsonapi.org",
|
5
|
+
"oneOf": [
|
6
|
+
{
|
7
|
+
"$ref": "#/definitions/success"
|
8
|
+
},
|
9
|
+
{
|
10
|
+
"$ref": "#/definitions/failure"
|
11
|
+
},
|
12
|
+
{
|
13
|
+
"$ref": "#/definitions/info"
|
14
|
+
}
|
15
|
+
],
|
16
|
+
|
17
|
+
"definitions": {
|
18
|
+
"success": {
|
19
|
+
"type": "object",
|
20
|
+
"required": [
|
21
|
+
"data"
|
22
|
+
],
|
23
|
+
"properties": {
|
24
|
+
"data": {
|
25
|
+
"$ref": "#/definitions/data"
|
26
|
+
},
|
27
|
+
"included": {
|
28
|
+
"description": "To reduce the number of HTTP requests, servers **MAY** allow responses that include related resources along with the requested primary resources. Such responses are called \"compound documents\".",
|
29
|
+
"type": "array",
|
30
|
+
"items": {
|
31
|
+
"$ref": "#/definitions/resource"
|
32
|
+
},
|
33
|
+
"uniqueItems": true
|
34
|
+
},
|
35
|
+
"meta": {
|
36
|
+
"$ref": "#/definitions/meta"
|
37
|
+
},
|
38
|
+
"links": {
|
39
|
+
"description": "Link members related to the primary data.",
|
40
|
+
"allOf": [
|
41
|
+
{
|
42
|
+
"$ref": "#/definitions/links"
|
43
|
+
},
|
44
|
+
{
|
45
|
+
"$ref": "#/definitions/pagination"
|
46
|
+
}
|
47
|
+
]
|
48
|
+
},
|
49
|
+
"jsonapi": {
|
50
|
+
"$ref": "#/definitions/jsonapi"
|
51
|
+
}
|
52
|
+
},
|
53
|
+
"additionalProperties": false
|
54
|
+
},
|
55
|
+
"failure": {
|
56
|
+
"type": "object",
|
57
|
+
"required": [
|
58
|
+
"errors"
|
59
|
+
],
|
60
|
+
"properties": {
|
61
|
+
"errors": {
|
62
|
+
"type": "array",
|
63
|
+
"items": {
|
64
|
+
"$ref": "#/definitions/error"
|
65
|
+
},
|
66
|
+
"uniqueItems": true
|
67
|
+
},
|
68
|
+
"meta": {
|
69
|
+
"$ref": "#/definitions/meta"
|
70
|
+
},
|
71
|
+
"jsonapi": {
|
72
|
+
"$ref": "#/definitions/jsonapi"
|
73
|
+
}
|
74
|
+
},
|
75
|
+
"additionalProperties": false
|
76
|
+
},
|
77
|
+
"info": {
|
78
|
+
"type": "object",
|
79
|
+
"required": [
|
80
|
+
"meta"
|
81
|
+
],
|
82
|
+
"properties": {
|
83
|
+
"meta": {
|
84
|
+
"$ref": "#/definitions/meta"
|
85
|
+
},
|
86
|
+
"links": {
|
87
|
+
"$ref": "#/definitions/links"
|
88
|
+
},
|
89
|
+
"jsonapi": {
|
90
|
+
"$ref": "#/definitions/jsonapi"
|
91
|
+
}
|
92
|
+
},
|
93
|
+
"additionalProperties": false
|
94
|
+
},
|
95
|
+
|
96
|
+
"meta": {
|
97
|
+
"description": "Non-standard meta-information that can not be represented as an attribute or relationship.",
|
98
|
+
"type": "object",
|
99
|
+
"additionalProperties": true
|
100
|
+
},
|
101
|
+
"data": {
|
102
|
+
"description": "The document's \"primary data\" is a representation of the resource or collection of resources targeted by a request.",
|
103
|
+
"oneOf": [
|
104
|
+
{
|
105
|
+
"$ref": "#/definitions/resource"
|
106
|
+
},
|
107
|
+
{
|
108
|
+
"description": "An array of resource objects, an array of resource identifier objects, or an empty array ([]), for requests that target resource collections.",
|
109
|
+
"type": "array",
|
110
|
+
"items": {
|
111
|
+
"$ref": "#/definitions/resource"
|
112
|
+
},
|
113
|
+
"uniqueItems": true
|
114
|
+
},
|
115
|
+
{
|
116
|
+
"description": "null if the request is one that might correspond to a single resource, but doesn't currently.",
|
117
|
+
"type": "null"
|
118
|
+
}
|
119
|
+
]
|
120
|
+
},
|
121
|
+
"resource": {
|
122
|
+
"description": "\"Resource objects\" appear in a JSON API document to represent resources.",
|
123
|
+
"type": "object",
|
124
|
+
"required": [
|
125
|
+
"type",
|
126
|
+
"id"
|
127
|
+
],
|
128
|
+
"properties": {
|
129
|
+
"type": {
|
130
|
+
"type": "string"
|
131
|
+
},
|
132
|
+
"id": {
|
133
|
+
"type": "string"
|
134
|
+
},
|
135
|
+
"attributes": {
|
136
|
+
"$ref": "#/definitions/attributes"
|
137
|
+
},
|
138
|
+
"relationships": {
|
139
|
+
"$ref": "#/definitions/relationships"
|
140
|
+
},
|
141
|
+
"links": {
|
142
|
+
"$ref": "#/definitions/links"
|
143
|
+
},
|
144
|
+
"meta": {
|
145
|
+
"$ref": "#/definitions/meta"
|
146
|
+
}
|
147
|
+
},
|
148
|
+
"additionalProperties": false
|
149
|
+
},
|
150
|
+
|
151
|
+
"links": {
|
152
|
+
"description": "A resource object **MAY** contain references to other resource objects (\"relationships\"). Relationships may be to-one or to-many. Relationships can be specified by including a member in a resource's links object.",
|
153
|
+
"type": "object",
|
154
|
+
"properties": {
|
155
|
+
"self": {
|
156
|
+
"description": "A `self` member, whose value is a URL for the relationship itself (a \"relationship URL\"). This URL allows the client to directly manipulate the relationship. For example, it would allow a client to remove an `author` from an `article` without deleting the people resource itself.",
|
157
|
+
"type": "string",
|
158
|
+
"format": "uri"
|
159
|
+
},
|
160
|
+
"related": {
|
161
|
+
"$ref": "#/definitions/link"
|
162
|
+
}
|
163
|
+
},
|
164
|
+
"additionalProperties": true
|
165
|
+
},
|
166
|
+
"link": {
|
167
|
+
"description": "A link **MUST** be represented as either: a string containing the link's URL or a link object.",
|
168
|
+
"oneOf": [
|
169
|
+
{
|
170
|
+
"description": "A string containing the link's URL.",
|
171
|
+
"type": "string",
|
172
|
+
"format": "uri"
|
173
|
+
},
|
174
|
+
{
|
175
|
+
"type": "object",
|
176
|
+
"required": [
|
177
|
+
"href"
|
178
|
+
],
|
179
|
+
"properties": {
|
180
|
+
"href": {
|
181
|
+
"description": "A string containing the link's URL.",
|
182
|
+
"type": "string",
|
183
|
+
"format": "uri"
|
184
|
+
},
|
185
|
+
"meta": {
|
186
|
+
"$ref": "#/definitions/meta"
|
187
|
+
}
|
188
|
+
}
|
189
|
+
}
|
190
|
+
]
|
191
|
+
},
|
192
|
+
|
193
|
+
"attributes": {
|
194
|
+
"description": "Members of the attributes object (\"attributes\") represent information about the resource object in which it's defined.",
|
195
|
+
"type": "object",
|
196
|
+
"patternProperties": {
|
197
|
+
"^(?!relationships$|links$)\\w[-\\w_]*$": {
|
198
|
+
"description": "Attributes may contain any valid JSON value."
|
199
|
+
}
|
200
|
+
},
|
201
|
+
"additionalProperties": false
|
202
|
+
},
|
203
|
+
|
204
|
+
"relationships": {
|
205
|
+
"description": "Members of the relationships object (\"relationships\") represent references from the resource object in which it's defined to other resource objects.",
|
206
|
+
"type": "object",
|
207
|
+
"patternProperties": {
|
208
|
+
"^\\w[-\\w_]*$": {
|
209
|
+
"properties": {
|
210
|
+
"links": {
|
211
|
+
"$ref": "#/definitions/links"
|
212
|
+
},
|
213
|
+
"data": {
|
214
|
+
"description": "Member, whose value represents \"resource linkage\".",
|
215
|
+
"oneOf": [
|
216
|
+
{
|
217
|
+
"$ref": "#/definitions/relationshipToOne"
|
218
|
+
},
|
219
|
+
{
|
220
|
+
"$ref": "#/definitions/relationshipToMany"
|
221
|
+
}
|
222
|
+
]
|
223
|
+
},
|
224
|
+
"meta": {
|
225
|
+
"$ref": "#/definitions/meta"
|
226
|
+
}
|
227
|
+
},
|
228
|
+
"additionalProperties": false
|
229
|
+
}
|
230
|
+
},
|
231
|
+
"additionalProperties": false
|
232
|
+
},
|
233
|
+
"relationshipToOne": {
|
234
|
+
"description": "References to other resource objects in a to-one (\"relationship\"). Relationships can be specified by including a member in a resource's links object.",
|
235
|
+
"anyOf": [
|
236
|
+
{
|
237
|
+
"$ref": "#/definitions/empty"
|
238
|
+
},
|
239
|
+
{
|
240
|
+
"$ref": "#/definitions/linkage"
|
241
|
+
}
|
242
|
+
]
|
243
|
+
},
|
244
|
+
"relationshipToMany": {
|
245
|
+
"description": "An array of objects each containing \"type\" and \"id\" members for to-many relationships.",
|
246
|
+
"type": "array",
|
247
|
+
"items": {
|
248
|
+
"$ref": "#/definitions/linkage"
|
249
|
+
},
|
250
|
+
"uniqueItems": true
|
251
|
+
},
|
252
|
+
"empty": {
|
253
|
+
"description": "Describes an empty to-one relationship.",
|
254
|
+
"type": "null"
|
255
|
+
},
|
256
|
+
"linkage": {
|
257
|
+
"description": "The \"type\" and \"id\" to non-empty members.",
|
258
|
+
"type": "object",
|
259
|
+
"required": [
|
260
|
+
"type",
|
261
|
+
"id"
|
262
|
+
],
|
263
|
+
"properties": {
|
264
|
+
"type": {
|
265
|
+
"type": "string"
|
266
|
+
},
|
267
|
+
"id": {
|
268
|
+
"type": "string"
|
269
|
+
},
|
270
|
+
"meta": {
|
271
|
+
"$ref": "#/definitions/meta"
|
272
|
+
}
|
273
|
+
},
|
274
|
+
"additionalProperties": false
|
275
|
+
},
|
276
|
+
"pagination": {
|
277
|
+
"type": "object",
|
278
|
+
"properties": {
|
279
|
+
"first": {
|
280
|
+
"description": "The first page of data",
|
281
|
+
"oneOf": [
|
282
|
+
{ "type": "string", "format": "uri" },
|
283
|
+
{ "type": "null" }
|
284
|
+
]
|
285
|
+
},
|
286
|
+
"last": {
|
287
|
+
"description": "The last page of data",
|
288
|
+
"oneOf": [
|
289
|
+
{ "type": "string", "format": "uri" },
|
290
|
+
{ "type": "null" }
|
291
|
+
]
|
292
|
+
},
|
293
|
+
"prev": {
|
294
|
+
"description": "The previous page of data",
|
295
|
+
"oneOf": [
|
296
|
+
{ "type": "string", "format": "uri" },
|
297
|
+
{ "type": "null" }
|
298
|
+
]
|
299
|
+
},
|
300
|
+
"next": {
|
301
|
+
"description": "The next page of data",
|
302
|
+
"oneOf": [
|
303
|
+
{ "type": "string", "format": "uri" },
|
304
|
+
{ "type": "null" }
|
305
|
+
]
|
306
|
+
}
|
307
|
+
}
|
308
|
+
},
|
309
|
+
|
310
|
+
"jsonapi": {
|
311
|
+
"description": "An object describing the server's implementation",
|
312
|
+
"type": "object",
|
313
|
+
"properties": {
|
314
|
+
"version": {
|
315
|
+
"type": "string"
|
316
|
+
},
|
317
|
+
"meta": {
|
318
|
+
"$ref": "#/definitions/meta"
|
319
|
+
}
|
320
|
+
},
|
321
|
+
"additionalProperties": false
|
322
|
+
},
|
323
|
+
|
324
|
+
"error": {
|
325
|
+
"type": "object",
|
326
|
+
"properties": {
|
327
|
+
"id": {
|
328
|
+
"description": "A unique identifier for this particular occurrence of the problem.",
|
329
|
+
"type": "string"
|
330
|
+
},
|
331
|
+
"links": {
|
332
|
+
"$ref": "#/definitions/links"
|
333
|
+
},
|
334
|
+
"status": {
|
335
|
+
"description": "The HTTP status code applicable to this problem, expressed as a string value.",
|
336
|
+
"type": "string"
|
337
|
+
},
|
338
|
+
"code": {
|
339
|
+
"description": "An application-specific error code, expressed as a string value.",
|
340
|
+
"type": "string"
|
341
|
+
},
|
342
|
+
"title": {
|
343
|
+
"description": "A short, human-readable summary of the problem. It **SHOULD NOT** change from occurrence to occurrence of the problem, except for purposes of localization.",
|
344
|
+
"type": "string"
|
345
|
+
},
|
346
|
+
"detail": {
|
347
|
+
"description": "A human-readable explanation specific to this occurrence of the problem.",
|
348
|
+
"type": "string"
|
349
|
+
},
|
350
|
+
"source": {
|
351
|
+
"type": "object",
|
352
|
+
"properties": {
|
353
|
+
"pointer": {
|
354
|
+
"description": "A JSON Pointer [RFC6901] to the associated entity in the request document [e.g. \"/data\" for a primary data object, or \"/data/attributes/title\" for a specific attribute].",
|
355
|
+
"type": "string"
|
356
|
+
},
|
357
|
+
"parameter": {
|
358
|
+
"description": "A string indicating which query parameter caused the error.",
|
359
|
+
"type": "string"
|
360
|
+
}
|
361
|
+
}
|
362
|
+
},
|
363
|
+
"meta": {
|
364
|
+
"$ref": "#/definitions/meta"
|
365
|
+
}
|
366
|
+
},
|
367
|
+
"additionalProperties": false
|
368
|
+
}
|
369
|
+
}
|
370
|
+
}
|
metadata
ADDED
@@ -0,0 +1,294 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rspec-matchers-adhere_to_schema
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Pooyan Khosravi
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-03-11 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rspec-matcher
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: json-schema
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: gemsmith
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: pry
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: pry-byebug
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: pry-remote
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: pry-state
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: pry-rescue
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: pry-stack_explorer
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: rspec
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - ">="
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0'
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - ">="
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0'
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: rb-fsevent
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - ">="
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0'
|
174
|
+
type: :development
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - ">="
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '0'
|
181
|
+
- !ruby/object:Gem::Dependency
|
182
|
+
name: guard-rspec
|
183
|
+
requirement: !ruby/object:Gem::Requirement
|
184
|
+
requirements:
|
185
|
+
- - ">="
|
186
|
+
- !ruby/object:Gem::Version
|
187
|
+
version: '0'
|
188
|
+
type: :development
|
189
|
+
prerelease: false
|
190
|
+
version_requirements: !ruby/object:Gem::Requirement
|
191
|
+
requirements:
|
192
|
+
- - ">="
|
193
|
+
- !ruby/object:Gem::Version
|
194
|
+
version: '0'
|
195
|
+
- !ruby/object:Gem::Dependency
|
196
|
+
name: terminal-notifier
|
197
|
+
requirement: !ruby/object:Gem::Requirement
|
198
|
+
requirements:
|
199
|
+
- - ">="
|
200
|
+
- !ruby/object:Gem::Version
|
201
|
+
version: '0'
|
202
|
+
type: :development
|
203
|
+
prerelease: false
|
204
|
+
version_requirements: !ruby/object:Gem::Requirement
|
205
|
+
requirements:
|
206
|
+
- - ">="
|
207
|
+
- !ruby/object:Gem::Version
|
208
|
+
version: '0'
|
209
|
+
- !ruby/object:Gem::Dependency
|
210
|
+
name: terminal-notifier-guard
|
211
|
+
requirement: !ruby/object:Gem::Requirement
|
212
|
+
requirements:
|
213
|
+
- - ">="
|
214
|
+
- !ruby/object:Gem::Version
|
215
|
+
version: '0'
|
216
|
+
type: :development
|
217
|
+
prerelease: false
|
218
|
+
version_requirements: !ruby/object:Gem::Requirement
|
219
|
+
requirements:
|
220
|
+
- - ">="
|
221
|
+
- !ruby/object:Gem::Version
|
222
|
+
version: '0'
|
223
|
+
- !ruby/object:Gem::Dependency
|
224
|
+
name: rubocop
|
225
|
+
requirement: !ruby/object:Gem::Requirement
|
226
|
+
requirements:
|
227
|
+
- - ">="
|
228
|
+
- !ruby/object:Gem::Version
|
229
|
+
version: '0'
|
230
|
+
type: :development
|
231
|
+
prerelease: false
|
232
|
+
version_requirements: !ruby/object:Gem::Requirement
|
233
|
+
requirements:
|
234
|
+
- - ">="
|
235
|
+
- !ruby/object:Gem::Version
|
236
|
+
version: '0'
|
237
|
+
- !ruby/object:Gem::Dependency
|
238
|
+
name: codeclimate-test-reporter
|
239
|
+
requirement: !ruby/object:Gem::Requirement
|
240
|
+
requirements:
|
241
|
+
- - ">="
|
242
|
+
- !ruby/object:Gem::Version
|
243
|
+
version: '0'
|
244
|
+
type: :development
|
245
|
+
prerelease: false
|
246
|
+
version_requirements: !ruby/object:Gem::Requirement
|
247
|
+
requirements:
|
248
|
+
- - ">="
|
249
|
+
- !ruby/object:Gem::Version
|
250
|
+
version: '0'
|
251
|
+
description: |-
|
252
|
+
checks if expected adheres to specified json schema document. document can
|
253
|
+
be another object or name of a file containing it.
|
254
|
+
email:
|
255
|
+
- pekhee@gmail.com
|
256
|
+
executables: []
|
257
|
+
extensions: []
|
258
|
+
extra_rdoc_files:
|
259
|
+
- README.md
|
260
|
+
- LICENSE.md
|
261
|
+
files:
|
262
|
+
- LICENSE.md
|
263
|
+
- README.md
|
264
|
+
- lib/rspec/matchers/adhere_to_schema.rb
|
265
|
+
- lib/rspec/matchers/adhere_to_schema/identity.rb
|
266
|
+
- lib/tasks/rspec.rake
|
267
|
+
- lib/tasks/rubocop.rake
|
268
|
+
- vendor/jsonapi.schema
|
269
|
+
homepage: https://github.com/pekhee/rspec_matchers_adhere_to_schema
|
270
|
+
licenses:
|
271
|
+
- MIT
|
272
|
+
metadata: {}
|
273
|
+
post_install_message:
|
274
|
+
rdoc_options: []
|
275
|
+
require_paths:
|
276
|
+
- lib
|
277
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
278
|
+
requirements:
|
279
|
+
- - ">="
|
280
|
+
- !ruby/object:Gem::Version
|
281
|
+
version: '0'
|
282
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
283
|
+
requirements:
|
284
|
+
- - ">="
|
285
|
+
- !ruby/object:Gem::Version
|
286
|
+
version: '0'
|
287
|
+
requirements: []
|
288
|
+
rubyforge_project:
|
289
|
+
rubygems_version: 2.4.5.1
|
290
|
+
signing_key:
|
291
|
+
specification_version: 4
|
292
|
+
summary: rspec matcher to check output agains a json schema document
|
293
|
+
test_files: []
|
294
|
+
has_rdoc:
|