JSON LD Validate

Validation of JSON LD documents.

Installation

Add this line to your Gemfile:

gem 'json-ld-validate'

RSpec matcher

Within your spec helper, require the gem:

require 'jsonld_validate'

And include the matchers within the rspec configuration:

RSpec.configure do |config|
  config.include JsonldValidate::Matchers
end

Usage

Manuel

You can run the validator manually by using the JsonldValidate::Validator class:

content = {}
v = JsonldValidate::Validator.new(content)

puts v.valid?

RSpec

You can validate a JSON string being valid JSON-LD with the be_valid_jsonld matcher:

require 'spec_helper'

RSpec.describe 'User API' do
    it 'provides json-ld' do
        get :user, id: 1
        expect(response.parsed_body).to be_valid_jsonld
    end
end

Compatibility

JSON LD Validate ensures compatibility with the currently supported versions of the Ruby Language.