how to test exception?

def rescue_action_in_public(exception)
      case exception
        when LoginException
          headers["Status"] = "401 Unauthorized"
          goto_login
....

so I

def login!
  ....
  raise LoginException
end

but I don't know how to test it under functionals test

when ran rake test:functionals always show me exception so can't to test
step 2 goto_login

You can use ruby's assert_raise method

assert_raise LoginException do
  # whatever
end

More info can be found here http://www.ruby-doc.org/stdlib/libdoc/test/unit/rdoc/classes/Test/Unit/Assertions.html

thx It's very useful for me
在 2008-05-06二的 19:16 -0700,Thiago Jackiw写道: