我的控制器中有这个代码,我想用功能测试来测试这个代码行.
raise ActiveRecord::RecordNotFound if @post.nil?
我应该使用哪种断言方法?
我用以下代码进行了try :
test "should return 404 if page doesn't exist." do
get :show, :url => ["nothing", "here"]
assert_response :missing
end
但这对我不起作用.得到了这个测试输出:
test_should_return_404_if_page_doesn't_exist.(PageControllerTest):
ActiveRecord::RecordNotFound: ActiveRecord::RecordNotFound
app/controllers/page_controller.rb:7:in `show'
/test/functional/page_controller_test.rb:21:in `test_should_return_404_if_page_doesn't_exist.'