summaryrefslogtreecommitdiff
path: root/spec/support/api/schema_matcher.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/support/api/schema_matcher.rb')
-rw-r--r--spec/support/api/schema_matcher.rb8
1 files changed, 8 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..e42d727672b
--- /dev/null
+++ b/spec/support/api/schema_matcher.rb
@@ -0,0 +1,8 @@
+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"
+
+ JSON::Validator.validate!(schema_path, response.body, options)
+ end
+end