Sha256: 3be1fef5f94bcee950819d2f80275936e8b0f8899602bbe203b5f66b1d549d39
Contents?: true
Size: 1.07 KB
Versions: 2
Compression:
Stored size: 1.07 KB
Contents
require 'pathname' require Pathname(__FILE__).dirname.expand_path.parent + 'spec_helper' describe DataMapper::Validate::WithinValidator do before(:all) do class Telephone include DataMapper::Resource property :id, Integer, :serial => true property :type_of_number, String, :auto_validation => false validates_within :type_of_number, :set => ['Home','Work','Cell'] end class Reciever include DataMapper::Resource property :id, Integer, :serial => true property :holder, String, :auto_validation => false, :default => 'foo' validates_within :holder, :set => ['foo', 'bar', 'bang'] end end it "should validate a value on an instance of a resource within a predefined set of values" do tel = Telephone.new tel.valid?.should_not == true tel.errors.full_messages.first.should == 'Type of number must be one of [Home, Work, Cell]' tel.type_of_number = 'Cell' tel.valid?.should == true end it "should validate a value by its default" do tel = Reciever.new tel.should be_valid end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
dm-validations-0.9.3 | spec/integration/within_validator_spec.rb |
dm-validations-0.9.2 | spec/integration/within_validator_spec.rb |