search for: test_cant_destroy_homepag

Displaying 1 result from an estimated 1 matches for "test_cant_destroy_homepag".

2006 Jul 18
2
Testing which RuntimeError is raised
...moment is: In my model file: # don''t destroy the home page (id = 1) before_destroy :dont_destroy_homepage def dont_destroy_homepage raise "You can''t delete the home page or you will get rid of your entire site" if id == 1 end Then in my test file: def test_cant_destroy_homepage homepage = pages(:homepage) assert_equal homepage.id, 1 # I would really love to figure out how to test what RuntimeError is raised assert_raise(RuntimeError) {homepage.destroy} end -- Cynthia Kiser