-
-
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
Fix error messages for string responses #49
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,20 +22,30 @@ | |
expect(response_for({})).not_to match_response_schema("foo_schema") | ||
end | ||
|
||
it "validates a JSON string" do | ||
create_schema("foo_schema", { | ||
"type" => "object", | ||
"required" => [ | ||
"id", | ||
], | ||
"properties" => { | ||
"id" => { "type" => "number" }, | ||
}, | ||
"additionalProperties" => false, | ||
}) | ||
context "when JSON is a string" do | ||
before(:each) do | ||
create_schema("foo_schema", { | ||
"type" => "object", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
"required" => [ | ||
"id", | ||
], | ||
"properties" => { | ||
"id" => { "type" => "number" }, | ||
}, | ||
"additionalProperties" => false, | ||
}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
end | ||
|
||
expect(response_for({ "id" => 1 }).body). | ||
to match_response_schema("foo_schema") | ||
it "validates when the schema matches" do | ||
expect({ "id" => 1 }.to_json). | ||
to match_response_schema("foo_schema") | ||
end | ||
|
||
it "fails with message when negated" do | ||
expect { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Avoid using {...} for multi-line blocks. |
||
expect({ "id" => "1" }.to_json).to match_response_schema("foo_schema") | ||
}.to raise_formatted_error(%{{ "type": "number" }}) | ||
end | ||
end | ||
|
||
it "fails when the body contains a property with the wrong type" do | ||
|
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.