Sha256: 9de82503e56f71ce34f32972e9da812ac0ffb0eb85812b9db02566a628dfb62c

Contents?: true

Size: 691 Bytes

Versions: 17

Compression:

Stored size: 691 Bytes

Contents

require "minitest_helper"

module Hermod
  module Validators
    describe AllowedValues do
      subject do
        AllowedValues.new(%w(Antelope Bear Cat Dog Elephant))
      end

      it "permits values in the list" do
        subject.valid?("Cat", {}).must_equal true
      end

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

      it "raises an error for values not in the list" do
        ex = proc { subject.valid?("Albatross", {}) }.must_raise InvalidInputError
        ex.message.must_equal "must be one of Antelope, Bear, Cat, Dog, or Elephant, not Albatross"
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

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