[rspec-users] Patch idea for rspec_on_rails

Ben Mabey ben at benmabey.com
Fri Oct 19 16:35:05 EDT 2007


I've been using a set of matchers that does this plus adds more AR basic 
matchers (such as validate_presence_of, etc..  - by testing the 
behavior.)  I got the base of my matchers from this blog:
http://spicycode.com/2007/4/2/rspec-expecation-matchers-part-ii

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.

-Ben

Jerrett Taylor wrote:
> We have a similar one, which works like:
>
>
> Foo.should have_association(:has_many, :conditions => "stuff", :through 
> => :bazes)
>
> we started off with should have_many  etc, but it became overcomplicated 
> with all the various things that you may want - so we changed to 
> have_association to make it simpler and ensure it will work with any/all 
> association options
>
> http://pastie.caboo.se/108976
>
>
>
>
>
> Russell Norris wrote:
>   
>> I recently wrote a matcher for testing AR associations which allows
>> you to specify things like:
>>
>>     Foo.should have_many(:bars).through(:bazes)
>>
>> I'm pretty darned proud of it and a couple of people have suggested
>> that I should submit it to the rspec_on_rails project. Before I go to
>> the trouble of writing out rdoc and fully spec'ing it, I just wanted
>> to make sure this was something the community would like.
>>
>> Instead of pasting in the code into the email, I thought I'd just make
>> a pastie and let those interested read it there:
>> http://pastie.caboo.se/108922
>>
>> I think it would make a nice addition to the current Rails matchers.
>> Here's hoping you do too.
>>
>> RSL
>> _______________________________________________
>> rspec-users mailing list
>> rspec-users at rubyforge.org
>> http://rubyforge.org/mailman/listinfo/rspec-users
>>   
>>     
>
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>   



More information about the rspec-users mailing list