Sha256: 946979944ad4b032287e69967e315141c343b45f918d4a145b05841001a3be3b
Contents?: true
Size: 726 Bytes
Versions: 26
Compression:
Stored size: 726 Bytes
Contents
require File.join(File.dirname(File.expand_path(__FILE__)), "spec_helper") describe "Sequel::Plugins::AfterInitialize" do before do @db = Sequel.mock(:host=>'mysql', :numrows=>1) @c = Class.new(Sequel::Model(@db[:test])) @c.class_eval do columns :id, :name plugin :after_initialize def after_initialize self.name *= 2 self.id *= 3 if id end end end it "should have after_initialize hook be called for new objects" do @c.new(:name=>'foo').values.should == {:name=>'foofoo'} end it "should have after_initialize hook be called for objects loaded from the database" do @c.call(:id=>1, :name=>'foo').values.should == {:id=>3, :name=>'foofoo'} end end
Version data entries
26 entries across 26 versions & 2 rubygems