-
-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support configuring matcher default options #46
Conversation
|
||
expect(response_for({ "id" => 1, "title" => "bar" })). | ||
to match_response_schema("foo_schema", strict: true) | ||
expect(response_for({ "id" => 1 })). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Redundant curly braces around a hash parameter.
}, | ||
}) | ||
|
||
expect(response_for({ "id" => 1, "title" => "bar" })). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Redundant curly braces around a hash parameter.
"id" => { "type" => "number" }, | ||
"title" => {"type" => "string"}, | ||
}, | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indent the right brace the same as the first position after the preceding left parenthesis.
context "when options are passed directly to the matcher" do | ||
it "forwards options to the validator" do | ||
create_schema("foo_schema", { | ||
"type" => "object", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use 2 spaces for indentation in a hash, relative to the first position after the preceding left parenthesis.
@@ -130,6 +113,52 @@ | |||
expect(invalid_response).not_to match_response_schema("collection") | |||
end | |||
|
|||
context "when options are passed directly to the matcher" do | |||
it "forwards options to the validator" do | |||
create_schema("foo_schema", { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Redundant curly braces around a hash parameter.
}, | ||
}) | ||
|
||
expect(response_for({ "id" => 1, "title" => "bar" })). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Redundant curly braces around a hash parameter.
}, | ||
}) | ||
|
||
expect(response_for({ "id" => 1, "title" => "bar" })). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Redundant curly braces around a hash parameter.
"id" => { "type" => "number" }, | ||
"title" => { "type" => "string" }, | ||
}, | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indent the right brace the same as the first position after the preceding left parenthesis.
"id" => { "type" => "number" }, | ||
"title" => { "type" => "string" }, | ||
}, | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indent the right brace the same as the first position after the preceding left parenthesis.
}, | ||
}) | ||
|
||
expect(response_for({ "id" => 1, "title" => "bar" })). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Redundant curly braces around a hash parameter.
"id" => { "type" => "number" }, | ||
"title" => { "type" => "string" }, | ||
}, | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indent the right brace the same as the first position after the preceding left parenthesis.
}, | ||
}) | ||
|
||
expect(response_for({ "id" => 1, "title" => "bar" })). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Redundant curly braces around a hash parameter.
"id" => { "type" => "number" }, | ||
"title" => { "type" => "string" }, | ||
}, | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indent the right brace the same as the first position after the preceding left parenthesis.
Closes [#40]. To configure the default options passed to *all* matchers, call `JsonMatchers.configure`: ```rb JsonMatchers.configure do |config| config.options[:strict] = true end ``` A list of available options can be found [here][options]. [#40]: #40 [options]: https://github.com/ruby-json-schema/json-schema/blob/2.2.4/lib/json-schema/validator.rb#L160-L162
|
||
expect(response_for({ "id" => 1, "title" => "bar" })). | ||
to match_response_schema("foo_schema") | ||
expect(response_for({ "id" => 1 })). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Redundant curly braces around a hash parameter.
config.options[:strict] = true | ||
end | ||
|
||
expect(response_for({ "id" => 1, "title" => "bar" })). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Redundant curly braces around a hash parameter.
"id" => { "type" => "number" }, | ||
"title" => { "type" => "string" }, | ||
}, | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indent the right brace the same as the first position after the preceding left parenthesis.
context "when options are configured globally" do | ||
it "forwards them to the validator" do | ||
create_schema("foo_schema", { | ||
"type" => "object", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use 2 spaces for indentation in a hash, relative to the first position after the preceding left parenthesis.
|
||
context "when options are configured globally" do | ||
it "forwards them to the validator" do | ||
create_schema("foo_schema", { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Redundant curly braces around a hash parameter.
Closes #40.
To configure the default options passed to all matchers, call
JsonMatchers.configure
:A list of available options can be found here.