Sha256: 6adf4ec3b35db7f77967af56bf3005229c46f092692015d49ca1696ea3a57d4e

Contents?: true

Size: 643 Bytes

Versions: 5

Compression:

Stored size: 643 Bytes

Contents

require "minitest_helper"

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

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

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

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

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

Version data entries

5 entries across 5 versions & 1 rubygems

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