mirror of
https://github.com/discourse/discourse.git
synced 2024-11-24 20:26:35 +08:00
0a5f548635
As part of this move, we are also renaming `discourse-chat` to `chat`.
17 lines
474 B
Ruby
17 lines
474 B
Ruby
# 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"
|
|
pp object
|
|
raise e
|
|
end
|
|
end
|
|
end
|