Sha256: f9dbfb21fe5bbc8aa50eae361db2c7bdf0d2434102f0dd6084289d4840bf4a67

Contents?: true

Size: 655 Bytes

Versions: 5

Compression:

Stored size: 655 Bytes

Contents

require "minitest_helper"

module Hermod
  module Validators
    describe NonNegative do
      subject do
        NonNegative.new
      end

      it "allows positive values" do
        expect(subject.valid?(1, {})).must_equal true
      end

      it "allows zero values" do
        expect(subject.valid?(0, {})).must_equal true
      end

      it "allows blank values" do
        expect(subject.valid?(nil, {})).must_equal true
      end

      it "raises an error for negative values" do
        ex = expect { subject.valid?(-1, {}) }.must_raise InvalidInputError
        expect(ex.message).must_equal "cannot be negative"
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
hermod-3.3.0 spec/hermod/validators/non_negative_spec.rb
hermod-3.2.0 spec/hermod/validators/non_negative_spec.rb
hermod-3.0.0 spec/hermod/validators/non_negative_spec.rb
hermod-2.7.0 spec/hermod/validators/non_negative_spec.rb
hermod-2.7.0.pre.rc.1 spec/hermod/validators/non_negative_spec.rb