sfeley at gmail.com
Thu Feb 19 00:40:20 EST 2009
On Wed, Feb 18, 2009 at 11:42 PM, Yi Wen <hayafirst at gmail.com> wrote:
> Without this syntax sugar, we still have to test validates_presence_of to
> make sure it's there and won't broken, right?
Wrong. You don't have to test validates_presence_of. What matters,
and therefore what you should test, is whether the model will complain
at you if a particular value is left empty.
validates_presence_of happens to be the name of the method in
ActiveRecord that does that. But if you decide to write your own
check_to_see_if_this_thingy_is_in_my_whatsis() method that does the
same thing, a good *behavior* spec will not break. Because the
behavior remains the same.
If your spec breaks because you changed a method call, you're not
testing behavior any more. You're testing syntax.
Steve Eley (sfeley at gmail.com)
ESCAPE POD - The Science Fiction Podcast Magazine
More information about the rspec-users