-
-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove support for configuring validation options
In preparation for [#31][#31], this commit removes support for global and matcher-specific options, like `strict: true`. The [`json_schema` gem][gem] does not accept similar configuration options, so we'll remove support entirely. [#31]: #31 [gem]: https://github.com/brandur/json_schema#programmatic
- Loading branch information
1 parent
f840139
commit 48e7620
Showing
11 changed files
with
14 additions
and
198 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
master | ||
====== | ||
|
||
* *Breaking Change* - remove support for configuring validation options. | ||
|
||
0.9.0 | ||
===== | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -116,47 +116,6 @@ def test_GET_posts_returns_Posts | |
end | ||
``` | ||
|
||
### DEPRECATED: Passing options to the validator | ||
|
||
The matcher accepts options, which it passes to the validator: | ||
|
||
`spec/requests/posts_spec.rb` | ||
|
||
```ruby | ||
describe "GET /posts" do | ||
it "returns Posts" do | ||
get posts_path, format: :json | ||
|
||
expect(response.status).to eq 200 | ||
expect(response).to match_json_schema("posts", strict: true) | ||
end | ||
end | ||
``` | ||
|
||
A list of available options can be found [here][options]. | ||
|
||
[options]: https://github.com/ruby-json-schema/json-schema/blob/2.2.4/lib/json-schema/validator.rb#L160-L162 | ||
|
||
### DEPRECATED: Global matcher options | ||
|
||
To configure the default options passed to *all* matchers, call | ||
`JsonMatchers.configure`. | ||
|
||
`spec/support/json_matchers.rb`: | ||
|
||
```rb | ||
JsonMatchers.configure do |config| | ||
config.options[:strict] = true | ||
end | ||
``` | ||
|
||
A list of available options can be found [here][options]. | ||
|
||
### DEPRECATED: Default matcher options | ||
|
||
* `record_errors: true` - *NOTE* `json_matchers` will always set | ||
`record_errors: true`. This cannot be overridden. | ||
|
||
### Embedding other Schemas | ||
|
||
To DRY up your schema definitions, use JSON schema's `$ref`. | ||
|
@@ -203,9 +162,8 @@ To learn more about `$ref`, check out [Understanding JSON Schema Structuring](ht | |
|
||
## Upgrading from `0.9.x` | ||
|
||
After `[email protected]`, calls to `match_json_schema` and | ||
`match_response_schema` no longer accept options, and `JsonMatchers.configure` | ||
will been removed. | ||
Calls to `match_json_schema` and `match_response_schema` no longer accept | ||
options, and `JsonMatchers.configure` has been removed. | ||
|
||
## Contributing | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,20 +5,8 @@ module JsonMatchers | |
self.schema_root = File.join("spec", "support", "api", "schemas") | ||
end | ||
|
||
RSpec::Matchers.define :match_json_schema do |schema_name, **options| | ||
if options.present? | ||
warn <<-WARN | ||
DEPRECATION: | ||
After `[email protected]`, calls to `match_json_schema` and | ||
`match_response_schema` will no longer accept options. | ||
See https://github.com/thoughtbot/json_matchers/pull/31 for more information. | ||
WARN | ||
end | ||
|
||
assertion = JsonMatchers::Assertion.new(schema_name.to_s, options) | ||
RSpec::Matchers.define :match_json_schema do |schema_name| | ||
assertion = JsonMatchers::Assertion.new(schema_name.to_s) | ||
|
||
match do |json| | ||
assertion.valid?(json) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.