Fix matcher `match_response_schema`

parent f77c47a5
......@@ -26,7 +26,7 @@
parsed_response = JSON.parse(response.body)
expect(response).to match_response_schema('issue', array: true)
expect(response).to match_response_schema('issues')
expect(parsed_response.length).to eq 2
end
end
......
......@@ -29,7 +29,7 @@
parsed_response = JSON.parse(response.body)
expect(response).to match_response_schema('list', array: true)
expect(response).to match_response_schema('lists')
expect(parsed_response.length).to eq 3
end
......@@ -204,7 +204,7 @@ def remove_board_list(user:, list:)
it 'returns the defaults lists' do
generate_default_board_lists user: user
expect(response).to match_response_schema('list', array: true)
expect(response).to match_response_schema('lists')
end
end
......
{
"type": "array",
"items": { "$ref": "issue.json" }
}
{
"type": "array",
"items": { "$ref": "list.json" }
}
RSpec::Matchers.define :match_response_schema do |schema, options = {}|
RSpec::Matchers.define :match_response_schema do |schema, **options|
match do |response|
schema_directory = "#{Dir.pwd}/spec/fixtures/api/schemas"
schema_path = "#{schema_directory}/#{schema}.json"
list = options.fetch(:array, false)
JSON::Validator.validate!(schema_path, response.body, list: list)
JSON::Validator.validate!(schema_path, response.body, options)
end
end
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment