I’m having a lot of trouble stubbing out an association extension for
some view tests. Example rails code modeling a music album:
class Album < ActiveRecord::Base
has_many :songs do
find(:all, :conditions => ‘streamable = 1’)
So for a given Album instance (say @album), I need to be able to stub
both @album.songs and @album.songs.streamable in the same before block.
Is there a way for a stub to return one thing when called alone
(@album.songs) and another stub when the call is chained?
Before adding the extension, I just had @album.songs returning an
array of Song instances. The only thing I’ve thought of that would
work is temporarily extending Array itself to respond to #streamable,
but that feels ugly.
Thanks for any ideas,