[rspec-users] Stub ActionController::Base#params

Jed Hurt jed.hurt at gmail.com
Tue Oct 16 02:30:57 EDT 2007


Nevermind! I figured out that (in my case) I simply needed to instantiate an
instance of ActionController::Base and then stub the methods on the
instance:
@controller = ActionController::Base.new
@controller.stub!(:params).and_return(:foo => 'bar')

I then run my expectations against @controller, whereas before I was running
each of my expectations against a new instance of ActionController::Base (
i.e. ActionController::Base.new.should...)

On 10/16/07, Jed Hurt <jed.hurt at gmail.com> wrote:
>
> Has anyone had any success stubbing ActionController::Base#params? The
> following is not intercepting calls to params[:foo] in my controllers:
>
> ActionController::Base.stub!(:params).and_return(:foo => 'bar')
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/rspec-users/attachments/20071016/39dd934a/attachment.html 


More information about the rspec-users mailing list