Re: [rspec-users] mocking named_scope utilization

2008-11-06 Thread Pat Maddox
"Chris Flipse" <[EMAIL PROTECTED]> writes: > I dunno ... creating a bunch of joining methods seems to be an awfully > disjoint way to deal with something that is, admittedly, designed to > laugh in the face of the Law of Demeter. > > I've been handling chains through some heavy use of null_object

Re: [rspec-users] mocking named_scope utilization

2008-11-04 Thread Chris Flipse
Right. Example passed a block, but stub_chains didn't call it. Pretend there's a yield(hades) in there somewhere. On Tue, Nov 4, 2008 at 10:26 PM, Chris Flipse <[EMAIL PROTECTED]> wrote: > I dunno ... creating a bunch of joining methods seems to be an awfully > disjoint way to deal with somethi

Re: [rspec-users] mocking named_scope utilization

2008-11-04 Thread Chris Flipse
I dunno ... creating a bunch of joining methods seems to be an awfully disjoint way to deal with something that is, admittedly, designed to laugh in the face of the Law of Demeter. I've been handling chains through some heavy use of null_object stubs ... but, I've been doing that sort of manually.

Re: [rspec-users] mocking named_scope utilization

2008-11-04 Thread Pat Maddox
Fernando Perez <[EMAIL PROTECTED]> writes: > Therefore a workaround is to define an instance method: > -- > class Thing > def self.method1_and_method2(arg) > method1(arg).method2 > end > end I'm inclined to call this an improvement rather than a workaround :) Pat

Re: [rspec-users] mocking named_scope utilization

2008-11-04 Thread Fernando Perez
Here you go: It's not easy to test for the following named_scopes: -- Thing.method1(@current_user).method2.method3 :page => params[:page] -- I tried: -- Thing.should_receive(:method1).. Thing.should_receive(:method2).. Thing.should_receive(:method3) -- But testing for these three method calls did

Re: [rspec-users] mocking named_scope utilization

2008-11-04 Thread Matt Wynne
On 4 Nov 2008, at 21:48, Fernando Perez wrote: This trick to spec a named_scope method works very well. And it cleans up the chain mess in the controller. Which trick is that? Sorry if this sounds a bit patronising, but it does help if you quote the relevant bits of a post you're replying t

Re: [rspec-users] mocking named_scope utilization

2008-11-04 Thread Fernando Perez
This trick to spec a named_scope method works very well. And it cleans up the chain mess in the controller. -- Posted via http://www.ruby-forum.com/. ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-user

Re: [rspec-users] mocking named_scope utilization

2008-09-12 Thread Juanma Cervera
Very clear. Thank you very much Pat! -- Posted via http://www.ruby-forum.com/. ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users

Re: [rspec-users] mocking named_scope utilization

2008-09-12 Thread Pat Maddox
On Fri, Sep 12, 2008 at 5:20 AM, Juanma Cervera <[EMAIL PROTECTED]> wrote: > Hello, > I am having trouble to mock the chaining of named_scope in the > controller, also I would like to use will_paginate. > > def index > @things = Thing.allowed_for(@current_user).available.paginate :page => > params

[rspec-users] mocking named_scope utilization

2008-09-12 Thread Juanma Cervera
Hello, I am having trouble to mock the chaining of named_scope in the controller, also I would like to use will_paginate. def index @things = Thing.allowed_for(@current_user).available.paginate :page => params[:page] end ¿How to do it? Thanks Juanma Cervera -- Posted via http://www.ruby-forum