Sha256: 7a1fce1f714e03dcaed40dec4ff412d746f8b338017c6905b5070ee7d7f9eb2e
Contents?: true
Size: 902 Bytes
Versions: 2
Compression:
Stored size: 902 Bytes
Contents
require 'pathname' require Pathname(__FILE__).dirname.expand_path.parent + 'spec_helper' describe DataMapper::Validate::MethodValidator do before(:all) do class Ship include DataMapper::Resource property :id, Integer, :key => true property :name, String validates_with_method :fail_validation, :when => [:testing_failure] validates_with_method :pass_validation, :when => [:testing_success] def fail_validation return false, 'Validation failed' end def pass_validation return true end end end it "should validate via a method on the resource" do Ship.new.valid_for_testing_failure?.should == false Ship.new.valid_for_testing_success?.should == true ship = Ship.new ship.valid_for_testing_failure?.should == false ship.errors.full_messages.include?('Validation failed').should == true end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
dm-validations-0.9.3 | spec/integration/method_validator_spec.rb |
dm-validations-0.9.2 | spec/integration/method_validator_spec.rb |