Last active
December 28, 2015 00:19
-
-
Save letmein/7412908 to your computer and use it in GitHub Desktop.
RSpec matcher for json-schema
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RSpec::Matchers.define :match_schema do |schema_name| | |
match do |json| | |
schema = Rails.root.join("/path/to/your/schemas/#{schema_name}.json") | |
@errors = JSON::Validator.fully_validate(schema, json) | |
@errors.none? | |
end | |
failure_message_for_should do | |
@errors.first | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment