[rspec-users] some fun functionality for all your specs

Graeme Nelson graeme.nelson at gmail.com
Sun Feb 18 10:27:02 EST 2007


Thanks for the clarification, Courtenay.  I didn't realize that you  
were testing to see if :order actually exists.  I would still want to  
know if someone removed the 'belongs_to :orders', so I might still  
include Address.reflect_on_association :orders.

Thanks
Graeme Nelson

On Feb 17, 2007, at 9:52 PM, Courtenay wrote:

> On 2/17/07, Courtenay <court3nay at gmail.com> wrote:
>> On 2/17/07, Graeme Nelson <graeme.nelson at gmail.com> wrote:
>>> Hi.
>>>
>>> I am not sure what the have_valid_associations is really  
>>> testing.  If
>>> I have a model, like so:
>>>
>>> class Address < ActiveRecord::Base
>>>    belongs_to :order
>>> end
>>>
>>
>> try this
>>
>> class Address < ActiveRecord::Base
>>   belongs_to :fooxl
>> end
>>
>> make sure there's no Fooxl model.
>>
>> the 'valid associations' there means that your association actually
>> would work, were you to call it.  It's surprising how many
>> associations don't get tested at the model level.
>>
>
> you could also try
>
> belongs_to :order, :foreign_key => 'monkey_id'
>
> and it'll fail the spec.
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users



More information about the rspec-users mailing list