Hi I have the following code: def will_paginate(items, options = {}) options = options.merge(:container => true, :class => ''paging'') super(items, options) end I am curious about how to test that the call to super is infact being called with the added options. I have this it ''should call super on will_paginate'' do helper.stub!(:will_paginate).with([], {:container => true, :class => ''paging''}).and_return(true) helper.should_receive(:will_paginate).with([], {:container => true, :class => ''paging''}) helper.will_paginate([]) end But it fails as will_paginate is called with [] before being called with ([], {:container => true, :class => ''paging''}) I am relatively new to rspec, but trying to learn more - if there is a blog post on how to deal with these situations, please point me in the right direction. Help much appreciated. Ivor -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20081209/e9f0e080/attachment.html>
On 2008-12-09, at 06:29, Ivor Paul wrote:> Hi > > I have the following code: > > def will_paginate(items, options = {}) > options = options.merge(:container => true, :class => ''paging'') > super(items, options) > end > > I am curious about how to test that the call to super is infact > being called with the added options. > > I have this > > it ''should call super on will_paginate'' do > helper.stub!(:will_paginate).with([], {:container => > true, :class => ''paging''}).and_return(true) > helper.should_receive(:will_paginate).with([], {:container => > true, :class => ''paging''}) > helper.will_paginate([]) > end > > But it fails as will_paginate is called with [] before being called > with ([], {:container => true, :class => ''paging''}) > > I am relatively new to rspec, but trying to learn more - if there is > a blog post on how to deal with these situations, please point me in > the right direction. > > Help much appreciated. > > IvorG''day Ivor. See this thread for details: http://www.ruby-forum.com/topic/151744 -Nick
Thanks Nick the first approach seems the best for my situation. Appreciate the response Ivor On Tue, Dec 9, 2008 at 4:45 PM, Nick Hoffman <nick at deadorange.com> wrote:> On 2008-12-09, at 06:29, Ivor Paul wrote: > >> Hi >> >> I have the following code: >> >> def will_paginate(items, options = {}) >> options = options.merge(:container => true, :class => ''paging'') >> super(items, options) >> end >> >> I am curious about how to test that the call to super is infact being >> called with the added options. >> >> I have this >> >> it ''should call super on will_paginate'' do >> helper.stub!(:will_paginate).with([], {:container => true, :class => >> ''paging''}).and_return(true) >> helper.should_receive(:will_paginate).with([], {:container => true, >> :class => ''paging''}) >> helper.will_paginate([]) >> end >> >> But it fails as will_paginate is called with [] before being called with >> ([], {:container => true, :class => ''paging''}) >> >> I am relatively new to rspec, but trying to learn more - if there is a >> blog post on how to deal with these situations, please point me in the right >> direction. >> >> Help much appreciated. >> >> Ivor >> > > G''day Ivor. See this thread for details: > http://www.ruby-forum.com/topic/151744 > > -Nick > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20081210/dc7bed0f/attachment.html>