[rspec-users] Test::Unit Functional failure puzzle

Zach Dennis zach.dennis at gmail.com
Sun Nov 23 13:51:50 EST 2008

Bah, hit send on accident... here's the last create! example...

  def create
      @user = User.create! params[:user]
  rescue ActiveRecord::RecordInvalid
     # this won't work, because @user never gets assigned, since
create! raised an exception
     render :action => "new"

In any of the cases where you have to rescue an exception in a
controller action that will have the same affect of your test not
reporting the exception. If your application can handle returning a
default error page to the user then you're probably okay, but if you
need to re-render something for the user (like the data entry form)
then you won't want un-rescued exceptions for things like validation
to occur. And then you may not want to rescue exceptions at all, and
you might just end back up with #save.


Zach Dennis

More information about the rspec-users mailing list