[rspec-users] proxy associantion on controllers

Joseph Wilk josephwilk at joesniff.co.uk
Fri Dec 5 09:15:55 EST 2008


Daniel Lopes wrote:
> Thanks Newman, I already try this but get strange error:
>
>   before do
>     @current_user = mock_model(User, :id => 1)
>     controller.stub!(:check_administrator_role).and_return(true)
>     User.stub(:find).with(1).and_return(@user) # <=<=<=<=<=<=

Looks like a missing '!':

User.stub!(:find).with(1).and_return(@user) # <=<=<=<=<=<=

--
Joseph Wilk

>   end
>
> The error:
> undefined method `stub' for #<Class:0x23a5f3c>
>
>
> Atenciosamente,
>
> Daniel Lopes    Area Criações
> Design, Websites e Sistemas Web
>
> Visite:  http://www.areacriacoes.com.br/projects
>           http://blog.areacriacoes.com.br/
>
> * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
> * * * *
> 55 (31) 3077-4560  /  55 (31) 8808-8748  /  55 (31) 8737-7501
>
>
> On Fri, Dec 5, 2008 at 11:58 AM, Newman Huang <lists at ruby-forum.com 
> <mailto:lists at ruby-forum.com>> wrote:
>
>
>     try:
>
>     #@user = User.find(params[:user_id])
>     User.stub(:find).with(xx).and_return(@user)
>     --
>     Posted via http://www.ruby-forum.com/.
>     _______________________________________________
>     rspec-users mailing list
>     rspec-users at rubyforge.org <mailto:rspec-users at rubyforge.org>
>     http://rubyforge.org/mailman/listinfo/rspec-users
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users



More information about the rspec-users mailing list