Sha256: 4c9b6dec8c549da9f3301d5a6e402fbe52efae3eb6ac3e82fb4d4edc2eaf98b7
Contents?: true
Size: 1.09 KB
Versions: 4
Compression:
Stored size: 1.09 KB
Contents
require File.dirname(__FILE__) + "/spec_helper" describe DataMapper::Callbacks do it "should allow for a callback to be set, then called" do example = Class.new do include DataMapper::CallbacksHelper attr_accessor :name def initialize(name) @name = name end before_save 'name = "bob"' before_validation { |instance| instance.name = 'Barry White Returns!' } end.new('Barry White') example.class::callbacks.execute(:before_save, example) example.name.should == 'Barry White' example.class::callbacks.execute(:before_validation, example) example.name.should == 'Barry White Returns!' end it "should allow method delegation by passing symbols to the callback definitions" do example = Class.new do include DataMapper::CallbacksHelper attr_accessor :name before_save :test def test @name = 'Walter' end end.new example.class::callbacks.execute(:before_save, example) example.name.should == 'Walter' end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
datamapper-0.2.1 | spec/callbacks_spec.rb |
datamapper-0.2.2 | spec/callbacks_spec.rb |
datamapper-0.2.3 | spec/callbacks_spec.rb |
datamapper-0.2.4 | spec/callbacks_spec.rb |