class Album < ActiveRecord::Base has_many :songs do def streamable find(:all, :conditions => 'streamable = 1') end end end
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? (@album.songs.streamable)
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, Chris Kampmeier http://www.shiftcommathree.com
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users