2022-11-02 09:41:30 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
RSpec::Matchers.define :match_response_schema do |schema|
|
|
|
|
match do |object|
|
|
|
|
schema_directory = "#{Dir.pwd}/plugins/chat/spec/support/api/schemas"
|
|
|
|
schema_path = "#{schema_directory}/#{schema}.json"
|
|
|
|
|
|
|
|
begin
|
|
|
|
JSON::Validator.validate!(schema_path, object, strict: true)
|
|
|
|
rescue JSON::Schema::ValidationError => e
|
|
|
|
puts "-- Printing response body after validation error\n"
|
2023-12-06 17:25:00 -05:00
|
|
|
pp object
|
2022-11-02 09:41:30 -04:00
|
|
|
raise e
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|