Sha256: d59dcf4363e91dcfb51f1d0910ee936cd39da077c08615748a39b834d2be3de4

Contents?: true

Size: 708 Bytes

Versions: 15

Compression:

Stored size: 708 Bytes

Contents

require "minitest_helper"

module Hermod
  module Validators
    describe Range do
      subject do
        Range.new(1..7)
      end

      it "allows values in the range" do
        subject.valid?(1, {}).must_equal true
        subject.valid?(7, {}).must_equal true
      end

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

      it "raises an error for values outwith the range" do
        ex = proc { subject.valid?(0, {}) }.must_raise InvalidInputError
        ex.message.must_equal "must be between 1 and 7"
      end

      it "can also take a min and max as arguments" do
        Range.new(1, 7).valid?(3, {}).must_equal true
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
hermod-2.6.2 spec/hermod/validators/range_spec.rb
hermod-2.6.1 spec/hermod/validators/range_spec.rb
hermod-2.5.3 spec/hermod/validators/range_spec.rb
hermod-2.5.2 spec/hermod/validators/range_spec.rb
hermod-2.5.1 spec/hermod/validators/range_spec.rb
hermod-2.5.0 spec/hermod/validators/range_spec.rb
hermod-2.4.1 spec/hermod/validators/range_spec.rb
hermod-2.4.0 spec/hermod/validators/range_spec.rb
hermod-2.2.0 spec/hermod/validators/range_spec.rb
hermod-2.1.0 spec/hermod/validators/range_spec.rb
hermod-1.2.9 spec/hermod/validators/range_spec.rb
hermod-1.2.8 spec/hermod/validators/range_spec.rb
hermod-1.2.7 spec/hermod/validators/range_spec.rb
hermod-1.2.6 spec/hermod/validators/range_spec.rb
hermod-1.2.5 spec/hermod/validators/range_spec.rb