Sha256: 257a9bfa97a484314b28e014330badcb97dc061e02a675f53990b4821d42b07f
Contents?: true
Size: 952 Bytes
Versions: 12
Compression:
Stored size: 952 Bytes
Contents
require File.expand_path(File.dirname(__FILE__) + '/../test_helper') module Functional class ValidatesInclusionOfTest < Test::Unit::TestCase test "given state not in list, when validated, then error is in the objects error collection" do klass = Class.new do include Validatable attr_accessor :state validates_inclusion_of :state, :within => %w(in out) end instance = klass.new instance.state = 'foo' instance.valid? assert_equal "is not in the list", instance.errors.on(:state) end test "given state in list, when validated, then no error is in the objects error collection" do klass = Class.new do include Validatable attr_accessor :state validates_inclusion_of :state, :within => %w(in out) end instance = klass.new instance.state = 'in' instance.valid? assert_nil instance.errors.on(:state) end end end
Version data entries
12 entries across 12 versions & 5 rubygems