Sha256: b8c18c420299c2597a89733903321748595458831f5a07743d60a19c627ad092
Contents?: true
Size: 1.14 KB
Versions: 14
Compression:
Stored size: 1.14 KB
Contents
require 'test_helper' # NOTE: A test for req and opt is part of validator_hash_test.rb module Schemacop module V2 class NilDisAllowTest < V2Test def test_req s = Schema.new do req? :o do type :boolean end req :r do type :boolean end end assert_nothing_raised { s.validate!(o: nil, r: false) } assert_nothing_raised { 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_nothing_raised { s.validate!(o: nil, r: false) } assert_nothing_raised { s.validate!(o: false, r: false) } assert_nothing_raised { s.validate!(r: true) } assert_nothing_raised { s.validate!({}) } assert_verr { s.validate!(o: true, r: nil) } assert_verr { s.validate!(o: nil, r: nil) } end end end end
Version data entries
14 entries across 14 versions & 1 rubygems