Sha256: 0a7226551ccd250c6554e85c0f1d451191454ac0f44f4399b67f6f8ee1d825ea
Contents?: true
Size: 1.03 KB
Versions: 3
Compression:
Stored size: 1.03 KB
Contents
require_relative '../../spec_helper' require_relative 'spec_helper' describe 'required_field_validator/plain_old_ruby_object_spec' do describe "A plain old Ruby object (not a DM resource)" do before do class PlainClass extend DataMapper::Validations::ClassMethods include DataMapper::Validations attr_accessor :accessor validates_presence_of :here, :empty, :nil, :accessor def here; "here" end def empty; "" end def nil; nil end end @pc = PlainClass.new end it "fails validation with empty, nil, or blank fields" do expect(@pc).not_to be_valid expect(@pc.errors.on(:empty)).to eq [ 'Empty must not be blank' ] expect(@pc.errors.on(:nil)).to eq [ 'Nil must not be blank' ] expect(@pc.errors.on(:accessor)).to eq [ 'Accessor must not be blank' ] end it "giving accessor a value removes validation error" do @pc.accessor = "full" @pc.valid? expect(@pc.errors.on(:accessor)).to be_nil end end end
Version data entries
3 entries across 3 versions & 1 rubygems