joshua.shapiro-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2006-Dec-28 13:24 UTC
problem with assert_raise in Unit Test
I''m running a simple unit test to validate that ActiveRecord raises an exception when I try and update a column with a duplicate foreign key. Inside the unit test, charge.time_logs << time_logs(:first) will generate ActiveRecord::StatementInvalid: Mysql::Error: #23000Duplicate entry ''20'' for key 2: UPDATE time_logs SET `task_id` = 1, `date_created` NULL, `time_charge_id` = 20, `hours` = 2.0, `log_entry` = NULL WHERE id = 2 However, assert_raise ActiveRecord::StatementInvalid do charge.time_logs << time_logs(:first) end will generate <ActiveRecord::StatementInvalid> exception expected but none was thrown. What am I doing wrong? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---