Sha256: c1d068c0f626252944662bf231ca80a0fcdad6020fc2a01ef98d85854992b10f
Contents?: true
Size: 818 Bytes
Versions: 30
Compression:
Stored size: 818 Bytes
Contents
require 'spec_helper' describe 'callbacks' do class Tree include CouchPotato::Persistence before_validation :grow_leaf property :leaf_count property :watered def grow_leaf self.leaf_count ||= 0 self.leaf_count += 1 end end class AppleTree < Tree attr_accessor :watered before_validation :water def water self.watered = true end def watered? watered end end context 'inheritance' do it "should call the callbacks of the super class" do tree = AppleTree.new :leaf_count => 1 tree.valid? tree.leaf_count.should == 2 end it "should call the callbacks of the child class" do tree = AppleTree.new :leaf_count => 1 tree.valid? tree.should be_watered end end end
Version data entries
30 entries across 30 versions & 3 rubygems