Sha256: 34e911fb6d7bc96cc8f583a77f3a3003ad27e7902995fbb7b029a37cb67568f2

Contents?: true

Size: 963 Bytes

Versions: 6

Compression:

Stored size: 963 Bytes

Contents

require 'test_helper'

module Schemacop
  class ValidatorIntegerTest < Minitest::Test
    def test_basic
      s = Schema.new do
        type :integer
      end
      assert_nil s.validate!(-3)
      assert_nil s.validate!(0)
      assert_nil s.validate!(15)
      assert_verr { s.validate!(0.0) }
    end

    def test_option_min
      s = Schema.new do
        type :integer, min: 6
      end

      assert_nil s.validate!(6)
      assert_nil s.validate!(7)
      assert_verr { s.validate!(5) }
    end

    def test_option_max
      s = Schema.new do
        type :integer, max: 7
      end

      assert_nil s.validate!(6)
      assert_nil s.validate!(7)
      assert_verr { s.validate!(8) }
    end

    def test_options_min_max
      s = Schema.new do
        type :integer, min: 6, max: 7
      end

      assert_nil s.validate!(6)
      assert_nil s.validate!(7)
      assert_verr { s.validate!(5) }
      assert_verr { s.validate!(8) }
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
schemacop-2.3.2 test/validator_integer_test.rb
schemacop-2.3.1 test/validator_integer_test.rb
schemacop-2.3.0 test/validator_integer_test.rb
schemacop-2.2.0 test/validator_integer_test.rb
schemacop-2.1.0 test/validator_integer_test.rb
schemacop-2.0.0 test/validator_integer_test.rb