[rspec-users] mocking methods in the controller.

David Chelimsky dchelimsky at gmail.com
Fri Jul 6 03:11:14 EDT 2007


On 7/5/07, Daniel N <has.sox at gmail.com> wrote:
> Hi,
>
> I'm very new to rspec so please be patient with me.
>
> I've tried to take some of my tests out of the controller specs to check for
> things that are rendered.
>
> This has not worked so well, since my views have the controller method
>
> current_user
>
> in quite a few places.
>
> Is there any way that I can define this so that my views will be executed?
> Will this same thing occur for all helper methods that are definied in the
> controller?

If I understand you correctly, you are trying to take tests for views
that were previously rails functional tests and turn them into rspec
view examples. If that is the case, you should be able to do this:

template.stub!(:current_user).and_return(mock_model(User))

If not, please provide an explicit example so we can better understand
what you're talking about.

Cheers,
David

>
> Cheers
> Daniel
>
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>


More information about the rspec-users mailing list