Sha256: db2e66061c841a9c7368b7f71d95a058d657ae7761ddb5946ff1f2962e01575c
Contents?: true
Size: 1003 Bytes
Versions: 6
Compression:
Stored size: 1003 Bytes
Contents
require 'test_helper' # Note: A test for req and opt is part of validator_hash_test.rb module Schemacop class NilDisAllowTest < Minitest::Test def test_req s = Schema.new do req? :o do type :boolean end req :r do type :boolean end end assert_nil s.validate!(o: nil, r: false) assert_nil s.validate!(o: false, r: false) assert_verr { s.validate!(o: true, r: nil) } assert_verr { s.validate!(o: nil, r: nil) } assert_verr { s.validate!(r: true) } end def test_opt s = Schema.new do opt :o do type :boolean end opt! :r do type :boolean end end assert_nil s.validate!(o: nil, r: false) assert_nil s.validate!(o: false, r: false) assert_nil s.validate!(r: true) assert_nil s.validate!({}) assert_verr { s.validate!(o: true, r: nil) } assert_verr { s.validate!(o: nil, r: nil) } end end end
Version data entries
6 entries across 6 versions & 1 rubygems