Reputation: 71
I need to stub a helper method that's included inside a controller. Yes it's bad practice but for now that's what what i have to live with.
class ApplicationController < ActionController::Base
include ApplicationHelper
Say application_helper has a method :foo
that's included inside the controller.
I've tried stubbing like:
controller.stub(:foo)
@helper = Object.new.extend ApplicationHelper; @helper.stub(:foo)
Upvotes: 2
Views: 275
Reputation: 1046
I've had success with this before:
@controller.stub(:foo)
Notice the @
before the controller
.
Upvotes: 1