Testing errors on a mailer

I have the following action written:

  # POST /designers.xml;contact
  def contact
    rescue Exception => e
      logger.error("Email from #{params[:fromEmail]} to
#{params[:toEmail]} errored with: #{e}")
      respond_to do |format|
        format.xml { render :xml => e.to_xml }
      respond_to do |format|
        format.xml { head :ok }

As you can see, I follow a different path if there are errors in email
delivery. My question?

How do I force that exception in a functional test? A simple mock is
not sufficient since I only want the exception to occur in one of my
tests. I've looked at the following code, but I'm not sure it fits
what I need to do:


Thanks in advance!

You could use Mocha (http://mocha.rubyforge.org) to do something like
the following...

def test_what_happens_when_exception_raised
  # post :contact
  # assertions

def test_what_happens_when_no_exception_raised
  get :contact
  # post :contact
  # assertions