Stub ActionController::Base#params

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’)

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…)

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs