2009/12/3 s.ross <cwdi...@gmail.com>: ... > I would suggest that it is not necessarily desirable to test every method in > a model. Rather, it is desirable to test whether your model does what it is > supposed to do -- irrespective of the methods used to achieve that end. This > makes the "refactor" of red/green/refactor much more pleasant because you > don't necessarily need to rewrite your tests (specs) just because you either > 1) added a method to factor out common functionality; or 2) changed some > method name in the guts of your model. The important point is that in a > proper spec, the model should *behave* as specified both before and after > refactoring. >
I disagree, not in the principle that a model should 'behave' as specified, but whether this can always easily be ensured by top level behavioural analysis. Sometimes special cases that should be tested are much more obvious when looking at low level functions than looking at high level behaviour. For example I would ensure that for each conditional statement in a method there is a test that checks the true and false path for each condition. Otherwise these may be executed in production, perhaps in some unusual situation, when they have not been tested. Colin -- 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-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.