[rspec-users] Collection proxies need to be stubbed ?

Brian Yamabe brian at yamabe.net
Mon Jan 22 10:58:44 EST 2007


> I'm sure that sooner or later you're going to come up w/ a model that
> isn't supported directly by rails, and then you need to think about
> all this stuff.
>
> <soapbox>
> Also, while this may be far from most people's minds, letting all of
> this AR goodness seep out past your model classes binds your
> application to AR. There are other persistence frameworks, like OG,
> that are promising. If you decided to give on a try, you'd have a much
> easier time if you encapsulate all of that goodness inside your models
> and expose methods that are framework neutral.
>
> Not saying that you shouldn't exploit AR goodness. Just that
> localizing the exploitation makes things more flexible in the long
> run.
> </soapbox>

Even before I got your <soapbox/> I was thinking about what to do if
this weren't using Rails. I still like the notion of an intermediary;  
a class
that manages the relationship between Users and Projects. This would
minimize any coupling between the User and Project classes and allow
for a richer set of relationships to be tracked (inactive project  
members,
inactive user projects, etc.). The intermediary class could either  
exploit the
"AR goodness" or not. I could hear someone crying, "YAGNI," but the
decoupling of User and Project is the main concern.  The flexibility  
comes
almost as a side effect.

---Brian Yamabe



More information about the rspec-users mailing list