[rspec-users] how to test a observer model?

Zhenning Guan lists at ruby-forum.com
Wed Nov 25 21:31:48 EST 2009


I have a user_observer, code like this:

def after_create(user)
 UserMailer.deliver_signup_notification(user)
 user.random_key = random_key_method
 user.save
end


  before do
    @user = mock_model(User)
    @user_observer = UserObserver.instance
  end

UserMailer.should_receive(:deliver_signup_notification).with(@user)
@user_observer.after_create(@user)
---------------------------------------

how can I test the random_key process?
-- 
Posted via http://www.ruby-forum.com/.


More information about the rspec-users mailing list