Sha256: 1cb76b0a8c0c36d0a7a69a85a18d9d3446816550b0700fc2329b83f6dc21f441

Contents?: true

Size: 1.15 KB

Versions: 36

Compression:

Stored size: 1.15 KB

Contents

require 'test_helper'

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

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

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

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

        assert_nothing_raised { s.validate!(6) }
        assert_nothing_raised { 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_nothing_raised { s.validate!(6) }
        assert_nothing_raised { s.validate!(7) }
        assert_verr { s.validate!(5) }
        assert_verr { s.validate!(8) }
      end
    end
  end
end

Version data entries

36 entries across 36 versions & 1 rubygems

Version Path
schemacop-3.0.9 test/unit/schemacop/v2/validator_integer_test.rb
schemacop-3.0.8 test/unit/schemacop/v2/validator_integer_test.rb
schemacop-3.0.7 test/unit/schemacop/v2/validator_integer_test.rb
schemacop-3.0.6 test/unit/schemacop/v2/validator_integer_test.rb
schemacop-3.0.5 test/unit/schemacop/v2/validator_integer_test.rb
schemacop-3.0.4 test/unit/schemacop/v2/validator_integer_test.rb
schemacop-3.0.3 test/unit/schemacop/v2/validator_integer_test.rb
schemacop-3.0.2 test/unit/schemacop/v2/validator_integer_test.rb
schemacop-3.0.1 test/unit/schemacop/v2/validator_integer_test.rb
schemacop-3.0.0 test/unit/schemacop/v2/validator_integer_test.rb
schemacop-3.0.0.rc5 test/unit/schemacop/v2/validator_integer_test.rb
schemacop-3.0.0.rc4 test/unit/schemacop/v2/validator_integer_test.rb
schemacop-3.0.0.rc3 test/unit/schemacop/v2/validator_integer_test.rb
schemacop-3.0.0.rc2 test/unit/schemacop/v2/validator_integer_test.rb
schemacop-3.0.0.rc1 test/unit/schemacop/v2/validator_integer_test.rb
schemacop-3.0.0.rc0 test/unit/schemacop/v2/validator_integer_test.rb