json_matchers 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ebd2f6c2a65cd0ad316c68b20ab44b7319b9fb47
4
- data.tar.gz: 2a09b12a688897b183f76678991985042d3cc3db
3
+ metadata.gz: ae47ba6e026a29f0f498146f78039dd5b65f75cb
4
+ data.tar.gz: e8d728527e3010c55cdd2019376bfb2c61aa2352
5
5
  SHA512:
6
- metadata.gz: c6404d6214cb53692199e0533f9b824c54feb6f3961ac34d43bfb69ce7c1212794f4e36de5fd7972aa3744d9f49318ad280798cc016d620ef215e0e3ed8545de
7
- data.tar.gz: 4068995034f0ad147fe14f4640b91cfb0d8d6262f17d900daf0b91af80f87d278b2ebca054c24553d644a43ae9de1eaa0d483e38b16be0a186d4dfd3c3202138
6
+ metadata.gz: bbb54160e7035e4cfe4d2ae9741604fc157166f85ff431b62fdc92240cd850ae6a82b2da4fed61d9936b8a9ad65c241319f50b86f8e2f7f38ea8c0974198f559
7
+ data.tar.gz: 64c775526e26c009d99660e98ef7f3fbf38b0ef0cc2087d4104a48feef1edc215a8261fdf7d619ea07795da76bff5ff1071ae829ddfbb56e2f48f396652e12a2
data/NEWS.md CHANGED
@@ -1,17 +1,68 @@
1
- # 0.2.0
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
- # 0.1.0
53
+ 0.1.0
54
+ =====
7
55
 
8
- ## Breaking Changes
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
- # 0.0.1
62
+ 0.0.1
63
+ =====
14
64
 
15
- ## Features
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
- "type": "object",
45
- "required": ["id", "title", "body"],
46
- "properties": {
47
- "id": { "type": "integer" },
48
- "title": { "type": "string" },
49
- "body": { "type": "string" }
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'll pass to the validator:
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: false)
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
- validator_options,
16
+ options,
21
17
  )
22
18
  rescue JSON::Schema::ValidationError => ex
23
19
  @validation_failure_message = ex.message
@@ -1,3 +1,3 @@
1
1
  module JsonMatchers
2
- VERSION = "0.4.0"
2
+ VERSION = "0.5.0"
3
3
  end
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.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-10-02 00:00:00.000000000 Z
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.4.8
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`