Displaying 1 result from an estimated 1 matches for "delete_associated_comments".
2008 Mar 17
4
RSpec''ing model association callbacks
...eady
developed my models classes and their callbacks.
Now i''m trying to get a 100% coverage of my code but i
cannot reach it because i do not understand how to
spec my callbacks.
Look at this for example:
----------------- User Model
class User < ActiveRecord::Base
before_destroy :delete_associated_comments
def delete_associated_comments
comments = Comment.find_all_by_user_id(self.id)
comments.each { |c|
c.destroy
}
end
end
----------------- User Spec
describe User, " being deleted" do
before(:each) do
end
it "should see deleted his own comments"...