Fix matcher `match_response_schema`

parent f77c47a5
...@@ -26,7 +26,7 @@ describe Projects::Boards::IssuesController do ...@@ -26,7 +26,7 @@ describe Projects::Boards::IssuesController do
parsed_response = JSON.parse(response.body) 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 expect(parsed_response.length).to eq 2
end end
end end
......
...@@ -29,7 +29,7 @@ describe Projects::Boards::ListsController do ...@@ -29,7 +29,7 @@ describe Projects::Boards::ListsController do
parsed_response = JSON.parse(response.body) 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 expect(parsed_response.length).to eq 3
end end
...@@ -204,7 +204,7 @@ describe Projects::Boards::ListsController do ...@@ -204,7 +204,7 @@ describe Projects::Boards::ListsController do
it 'returns the defaults lists' do it 'returns the defaults lists' do
generate_default_board_lists user: user generate_default_board_lists user: user
expect(response).to match_response_schema('list', array: true) expect(response).to match_response_schema('lists')
end end
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| match do |response|
schema_directory = "#{Dir.pwd}/spec/fixtures/api/schemas" schema_directory = "#{Dir.pwd}/spec/fixtures/api/schemas"
schema_path = "#{schema_directory}/#{schema}.json" 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
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