Sha256: 87be8c2e44d78cd119eb7f0c84fdf62d67749a66c48101dc5bc8548c3be676e7
Contents?: true
Size: 884 Bytes
Versions: 43
Compression:
Stored size: 884 Bytes
Contents
# frozen_string_literal: true require 'minitest/autorun' require_relative '../lib/twiglet/validator' describe Twiglet::Validator do let(:valid) before do schema = { "type" => "object", "required" => ["message"], "properties" => { "message" => { "type" => "string" } } } @validator = Twiglet::Validator.new(schema.to_json) end it 'does not raise when validation passes' do assert_equal(@validator.validate({ message: 'this is my message', foo: 'bar' }), true) end it 'raises when validation fails' do assert_raises JSON::Schema::ValidationError do @validator.validate({ message: true }) end end it 'is a no-op when validator is configured to swallow errors' do @validator.custom_error_handler = ->(e) { puts e } assert_nil(@validator.validate({ message: true })) end end
Version data entries
43 entries across 43 versions & 1 rubygems