Hi,
In my functional tests it was convenient to use:
@controller.expects(:admin?).at_least_once.returns(true)
to simulate requests which come from an admin user. But it seems that in
Rails 2.3.8 it’s gone away. What replaces it now?
Thanks
Hi,
In my functional tests it was convenient to use:
@controller.expects(:admin?).at_least_once.returns(true)
to simulate requests which come from an admin user. But it seems that in
Rails 2.3.8 it’s gone away. What replaces it now?
Thanks
Fernando P. wrote:
Hi,
In my functional tests it was convenient to use:
@controller.expects(:admin?).at_least_once.returns(true)
to simulate requests which come from an admin user. But it seems that in
Rails 2.3.8 it’s gone away. What replaces it now?
Anyone? Currently my apps are running test less because I can’t use
expects or whatever method to stub out some behavior.
Where could I find relevant information about that?
In my functional tests it was convenient to use:
@controller.expects(:admin?).at_least_once.returns(true)
to simulate requests which come from an admin user. But it seems that in
Rails 2.3.8 it’s gone away. What replaces it now?
Up, it’s important. Nobody uses functional tests here?
On Jul 29, 3:53 pm, Fernando P. [email protected] wrote:
In my functional tests it was convenient to use:
@controller.expects(:admin?).at_least_once.returns(true)
to simulate requests which come from an admin user. But it seems that in
Rails 2.3.8 it’s gone away. What replaces it now?Up, it’s important. Nobody uses functional tests here?
Should still work. What happens instead? What version were you
migrating from? That stuff is setup by ActionController::TestCase
Fred
Hi Fred,
require ‘test_helper’
class Admin::OrdersControllerTest < ActionController::TestCase
def setup
@controller = Admin::OrdersController.new
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
@controller.expects(:admin?).at_least_once.returns(true)
@order = Factory.order
end
def test_index
get :index
assert_response :success
end
end
Do you explicitly require mocha somewhere?
I don’t use mocha. Did rails delegate the stubbing to mocha recently? So
that could be my missing piece of the puzzle. Where should I require it
in? test_helper.rb?
By the way you no longer need to setup @controller/@request/@response -
actioncontroller::testcase does that for you
Indeed, I’ll update my tests accordingly, thanks for pointing that out.
On Jul 29, 5:23 pm, Fernando P. <li…@ruby-forum.
class Admin::OrdersControllerTest < ActionController::TestCase
def setup
@controller = Admin::OrdersController.new
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
@controller.expects(:admin?).at_least_once.returns(true)
@order = Factory.order
end
Do you explicitly require mocha somewhere? By the way you no longer
need to setup @controller/@request/@response -
actioncontroller::testcase does that for you
Fred
Fred
It seems that simply installing the mocha gem solved my problem.
On Jul 30, 10:53 am, Fernando P. [email protected] wrote:
Do you explicitly require mocha somewhere?
I don’t use mocha. Did rails delegate the stubbing to mocha recently? So
that could be my missing piece of the puzzle. Where should I require it
in? test_helper.rb?
it always has, but rails may have been accidentally requiring it for
you
Fred
it always has, but rails may have been accidentally requiring it for
youFred
That makes sense. Thanks Fred.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs