[rspec-users] ordering dependency in tests?

Fearless Fool lists at ruby-forum.com
Thu Feb 24 14:38:07 EST 2011


SOLVED -- it was an AR caching problem.  I had Factory code that was 
essentially doing:

def make_me_a_premise(opts = {})
    opts = MODEL_PREMISE_DEFAULTS.merge(opts)
    premise = Factory(:premise)
    Factory(:premise_group_member,
            :premise => premise,
            :premise_group => opts[:premise_group])
    ...
    premise
end

... which was properly creating a premise <=> premise_group association, 
but not informing the in-memory premise_group about the new association. 
adding:

    opts[:premise_group].reload

fixed everything.  @David and @Pat, thanks for helping point the way.

- ff

[PS: Is there a more Rails-y way do make the association that won't run 
into this problem?  And what about the case where the association 
carries a value with it -- you can't just do a push.]

-- 
Posted via http://www.ruby-forum.com/.


More information about the rspec-users mailing list