about summary refs log tree commit diff
path: root/spec/support/matchers/json/match_json_schema.rb
diff options
context:
space:
mode:
authorClaire <claire.github-309c@sitedethib.com>2022-12-15 20:25:25 +0100
committerClaire <claire.github-309c@sitedethib.com>2022-12-15 20:25:25 +0100
commitf3a4d57be14b40d1e3a6ad9e1a1f9337dafc872e (patch)
tree623c4b710fed94a7280587da7d66863ab489957c /spec/support/matchers/json/match_json_schema.rb
parent3868ba683d56dbbeecc839fdeaeb7b3d0b18bb9a (diff)
parentf847f67410c75036edb2c4b45d0db048af0481c9 (diff)
Merge branch 'main' into glitch-soc/merge-upstream
Conflicts:
- `README.md`:
  Discarded upstream changes: we have our own README
- `app/controllers/follower_accounts_controller.rb`:
  Port upstream's minor refactoring
Diffstat (limited to 'spec/support/matchers/json/match_json_schema.rb')
-rw-r--r--spec/support/matchers/json/match_json_schema.rb6
1 files changed, 6 insertions, 0 deletions
diff --git a/spec/support/matchers/json/match_json_schema.rb b/spec/support/matchers/json/match_json_schema.rb
new file mode 100644
index 000000000..5d9c9a618
--- /dev/null
+++ b/spec/support/matchers/json/match_json_schema.rb
@@ -0,0 +1,6 @@
+RSpec::Matchers.define :match_json_schema do |schema|
+  match do |input_json|
+    schema_path = Rails.root.join('spec', 'support', 'schema', "#{schema}.json").to_s
+    JSON::Validator.validate(schema_path, input_json, validate_schema: true)
+  end
+end