On Thu, Jul 3, 2008 at 8:23 PM, Ryan B. [email protected]
You don’t write tests for rails methods firstly.
To elaborate on this statement a little, you don’t want to test the
framework, i.e., you don’t want to test that destroy actually destroys
the model. That’s already well-tested by the framework.
Rather, focus your tests on the conditional behavior that you’re
adding around destroying the model, which is that destroy doesn’t
destroy the model if it’s the default record. For example,
some_model = SomeModel.create! :isdefault => true
make sure we get an error and/or we can still find the record
By focusing on what destroy does when :isdefault is true instead of
how it works (that before_destroy is used to check :isdefault), your
tests can be fairly immune to how you implement this behavior.
If someone wants to fill in the last line of the test, please do share.