[rspec-users] before_save model callback rspec testing

Yi Wen hayafirst at gmail.com
Fri Jun 20 11:15:03 EDT 2008


user.should_receive(:encrypt_password).with(your_password)
user.save

Is this what you want?

On Fri, Jun 20, 2008 at 10:12 AM, Csongor Bartus <lists at ruby-forum.com> wrote:
> hi all,
>
> i'm learning rspec and i can't figure out how to test if a callback is
> executed in a model.
>
> my model code is:
>
> class User < ActiveRecord::Base
>  before_save :encrypt_password
>
> ...
>
>  def encrypt(password)
>    self.class.encrypt(password, salt)
>  end
>
>
> thanks a lot,
> cs.
> --
> Posted via http://www.ruby-forum.com/.
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>


More information about the rspec-users mailing list