Topic: rspec after_create test
Hi folks.
i have 2 simple models
class User < ActiveRecord::Base
has_many :albums
after_save :add_default_album
private
def add_default_album
self.albums.create if self.albums.count == 0
end
endand
class Album < ActiveRecord::Base
attr_accessible :name, :user_id
belongs_to :user
endhow to test after_create callback?
actually i want create a new album for user automaticaly..
it "should reject email addresses identical up to case" do
Album.should_receive(:create)
user = Fabricate :user
user.albums.should be_equal(1)
endthis code is failing but actually album creates after creation of new user...