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

Version Path
schemacop-3.0.33 test/unit/schemacop/v2/collector_test.rb
schemacop-3.0.32 test/unit/schemacop/v2/collector_test.rb
schemacop-3.0.31 test/unit/schemacop/v2/collector_test.rb
schemacop-3.0.30 test/unit/schemacop/v2/collector_test.rb
schemacop-3.0.29 test/unit/schemacop/v2/collector_test.rb
schemacop-3.0.28 test/unit/schemacop/v2/collector_test.rb
schemacop-3.0.27 test/unit/schemacop/v2/collector_test.rb
schemacop-3.0.26 test/unit/schemacop/v2/collector_test.rb
schemacop-3.0.25 test/unit/schemacop/v2/collector_test.rb
schemacop-3.0.24 test/unit/schemacop/v2/collector_test.rb
schemacop-3.0.23 test/unit/schemacop/v2/collector_test.rb
schemacop-3.0.22 test/unit/schemacop/v2/collector_test.rb
schemacop-3.0.21 test/unit/schemacop/v2/collector_test.rb
schemacop-3.0.20 test/unit/schemacop/v2/collector_test.rb
schemacop-3.0.19 test/unit/schemacop/v2/collector_test.rb
schemacop-3.0.18 test/unit/schemacop/v2/collector_test.rb
schemacop-3.0.17 test/unit/schemacop/v2/collector_test.rb
schemacop-3.0.16 test/unit/schemacop/v2/collector_test.rb
schemacop-3.0.15 test/unit/schemacop/v2/collector_test.rb
schemacop-3.0.14 test/unit/schemacop/v2/collector_test.rb