[rspec-users] Patch idea for rspec_on_rails

Ben Mabey ben at benmabey.com
Fri Oct 19 17:09:26 EDT 2007


David Chelimsky wrote:
> On 10/19/07, Ben Mabey <ben at benmabey.com> wrote:
>   
>> I would think that something like this should be worked into
>> rpsec_on_rails.  Because it makes testing AR behavior very easy and
>> painless.  One line of code = One line of test code.
>>     
>
> I'd be hesitant to include it in rspec_on_rails. I don't really see
> this as testing AR *behaviour* at all. It's pure structure. To me this
> is no different than specifying that a Group should have an Array of
> Users. And the reason we don't want to specify that is that if we
> decide to change the Array to a Hash internally, without affecting
> Group's methods, then we'd have to change the specs.
>
> But I'd encourage you to publish this as a gem or plugin. I'm sure a
> lot of people would like to use it, in spite of my opinions.
>
> Cheers,
> David
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>   
Ok, well, when I said it tests AR behavior I referring to the other AR 
matchers and not the association matchers that we are talking about.  
Sorry for the confusion. This is a better example of what I mean:
http://pastie.caboo.se/109016

In this pastie we are actually testing the behavior for 
validate_presence_for, would you agree?  I can understand your 
hesitation about the association matchers but do you have similar 
reservations about having matchers that test the behavior of rails 
validations? 

I know that this topic comes up on the list at least every other week.  
And it is the same argument time after time:  You can mock the class out 
and make sure it receives the the validation call.. but doing it that 
way does not actually test the behavior... well it isn't our code so we 
shouldn't be testing it... but it is an important part of that model's 
behaviour that needs a spec for... etc...  Would including default 
validation matchers in rails_on_rspec be a bad thing just because of the 
difference of opinions on it?  I think it would be helpful to include 
them in rspec_on_rails, WDYT?

Thanks,
Ben



More information about the rspec-users mailing list