Try this:
current_user = mock_model(User)
controller.stub!(:current_user).and_return( current_user)
On Dec 20, 9:51 pm, "James H."
<james.herd... gmail.com> wrote:
> I'm scratching my head a little trying to figure out
how to mock and
> stub controller methods. For instance,
>
> def index
> # Where current_user is a protected controller
method
> articles = current_user.articles.find(:all)
> end
>
> That's a pretty common sort of call in a controller.
How are you guys
> mocking and stubbing such calls? I'm currently using
Mocha, but I
> doubt this will effect what your approach is.
>
> Ideas? Thoughts? Tips? I'm all ears.
>
> James
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Ruby on Rails" group.
To post to this group, send email to rubyonrails googlegroups.com
To unsubscribe from this group, send email to
rubyonrails-unsubscribe googlegroups.com
For more options, visit this group at http://gro
ups.google.com/group/rubyonrails
-~----------~----~----~----~------~----~------~--~---
|