matt at mattwynne.net
Thu Feb 19 03:29:11 EST 2009
On 19 Feb 2009, at 05:40, Stephen Eley wrote:
> 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.
I agree with you is why I've avoided using things like this:
As I understand it, this just checks that you wrote the correct line
of code in the the AR model class. As Pat said, there is so little
value in doing this it seems pointless to me.
I've not looked at the shoulda macros. Would they still pass if I
decided to replace my call to a rails validation helper with
check_to_see_if_this_thingy_is_in_my_whatsis()? Or are they just
reflecting on the model's calls to the rails framework?
More information about the rspec-users