You do not need to drown out any instance of PortfoliosController, only an instance that uses this test. This is available in the @controller variable, as described in the ActionController :: TestCase Documentation .
class PortfoliosControllerTest < ActionController::TestCase setup do @portfolio = portfolios(:p2) user = @portfolio.user token = Doorkeeper::AccessToken.create!(application_id: 'minitest', resource_owner_id: user.id) @controller.stubs(:doorkeeper_token).returns(token) end end
source share