Sha256: 30e0174fc95ae4465d344adccb6427761922b58cf1ffcac8ec16bb301e3f1372
Contents?: true
Size: 876 Bytes
Versions: 4
Compression:
Stored size: 876 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) 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
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
twiglet-3.1.3 | test/validator_test.rb |
twiglet-3.1.2 | test/validator_test.rb |
twiglet-3.1.1 | test/validator_test.rb |
twiglet-3.1.0 | test/validator_test.rb |