diff options
Diffstat (limited to 'spec/support/api/schema_matcher.rb')
| -rw-r--r-- | spec/support/api/schema_matcher.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/spec/support/api/schema_matcher.rb b/spec/support/api/schema_matcher.rb new file mode 100644 index 00000000000..929b637e5eb --- /dev/null +++ b/spec/support/api/schema_matcher.rb @@ -0,0 +1,9 @@ +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) + end +end |
