Re: [rspec-users] Mocking Rails association collections

2007-07-18 Thread David Chelimsky
On 7/18/07, court3nay <[EMAIL PROTECTED]> wrote: > Any chance of some prettier syntax for that? There's always a chance. What do you propose? > > --- > Courtenay > > On Jul 18, 2007, at 2:30 PM, "David Chelimsky" <[EMAIL PROTECTED]> > wrote: > > > On 7/18/07, Paul <[EMAIL PROTECTED]> wrote: >

Re: [rspec-users] Mocking Rails association collections

2007-07-18 Thread Paul
I eventually ended up using this, from a somewhat-related post to this list a couple months ago: def assoc_mock(stubs = {}) proxy = mock('association_proxy') stubs.each do |method, ret| proxy.stub!(method).and_return(ret) end proxy end Then I can do something like I wanted: @comment

Re: [rspec-users] Mocking Rails association collections

2007-07-18 Thread court3nay
Any chance of some prettier syntax for that? --- Courtenay On Jul 18, 2007, at 2:30 PM, "David Chelimsky" <[EMAIL PROTECTED]> wrote: > On 7/18/07, Paul <[EMAIL PROTECTED]> wrote: >> Rails model association collections allow you to do nifty things >> like: >> >> article.comments.find(:al

Re: [rspec-users] Mocking Rails association collections

2007-07-18 Thread court3nay
Any chance of some prettier syntax for that? --- Courtenay On Jul 18, 2007, at 2:30 PM, "David Chelimsky" <[EMAIL PROTECTED]> wrote: > On 7/18/07, Paul <[EMAIL PROTECTED]> wrote: >> Rails model association collections allow you to do nifty things >> like: >> >> article.comments.find(:all

Re: [rspec-users] Mocking Rails association collections

2007-07-18 Thread David Chelimsky
On 7/18/07, Paul <[EMAIL PROTECTED]> wrote: > Rails model association collections allow you to do nifty things like: > > article.comments.find(:all, :conditions => {:created_at > 1.day.ago}) > > Has anyone found a good way to mock this up? I'm currently doing this: > > @comment1 = mock_model(Co

[rspec-users] Mocking Rails association collections

2007-07-18 Thread Paul
Rails model association collections allow you to do nifty things like: article.comments.find(:all, :conditions => {:created_at > 1.day.ago}) Has anyone found a good way to mock this up? I'm currently doing this: @comment1 = mock_model(Comment) comments = mock(Array) comments.stub!(:find)