Sha256: 4d7474a315781b1ea9abf28e64d89065a5bbd1e2b63e6d12939b45f0304bf05e
Contents?: true
Size: 1.16 KB
Versions: 40
Compression:
Stored size: 1.16 KB
Contents
require 'test_helper' module Schemacop module V2 class CollectorTest < V2Test def test_no_root_node s = Schema.new do req :a, :string end col = s.validate(a: 0) assert col.exceptions.first[:path].first !~ %r{^/root}, 'Root node is present in the path.' end def test_correct_path s = Schema.new do req :long_symbol, :string req 'long_string', :string req 123, :string end col = s.validate('long_string' => 0, long_symbol: 0, 123 => 0) symbol = col.exceptions[0] string = col.exceptions[1] number = col.exceptions[2] assert symbol[:path].first =~ %r{^/long_symbol} assert string[:path].first =~ %r{^/long_string} assert number[:path].first =~ %r{^/123} end def test_nested_paths s = Schema.new do req :one do req :two, :string end req :three, :string end col = s.validate(one: { two: 0 }, three: 0) assert_equal 2, col.exceptions[0][:path].length assert_equal 1, col.exceptions[1][:path].length end end end end
Version data entries
40 entries across 40 versions & 1 rubygems