class Category < ActiveRecord::Base
acts_as_tree
end
How to test that acts_as_tree gets called?
Or that any other in class body method gets called?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Why would you want to test that it gets called? Of course it gets called!
What you really should be doing is testing that your application behaves the way you want it to behave. You write test cases illustrating how you want your application to behave, and then you run the test cases to check that the application does indeed behave that way.
You can write test cases checking that
Categoryinstances have parents and children, that you can retrieve the list of children given a parent, that you can create a newCategoryinstance and add it to some pre-existingCategoryinstance’s list of children, or various other behaviors important to your application.