Sha256: dc6a991d9a561bbd4bc56bea70ded723278f23869474a09fc150cca3f9a9f48c
Contents?: true
Size: 1.01 KB
Versions: 3
Compression:
Stored size: 1.01 KB
Contents
require 'spec_helper' require 'integration/required_field_validator/spec_helper' if HAS_SQLITE3 || HAS_MYSQL || HAS_POSTGRES describe "A plain old Ruby object (not a DM resource)" do before do class PlainClass extend DataMapper::Validate::ClassMethods include DataMapper::Validate attr_accessor :accessor validates_present :here, :empty, :nil, :accessor def here; "here" end def empty; "" end def nil; nil end end @pc = PlainClass.new end it "should fail validation with empty, nil, or blank fields" do @pc.should_not be_valid @pc.errors.on(:empty).should == [ 'Empty must not be blank' ] @pc.errors.on(:nil).should == [ 'Nil must not be blank' ] @pc.errors.on(:accessor).should == [ 'Accessor must not be blank' ] end it "giving accessor a value should remove validation error" do @pc.accessor = "full" @pc.valid? @pc.errors.on(:accessor).should be_nil end end end
Version data entries
3 entries across 3 versions & 1 rubygems