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)
I've had success with this before:
@controller.stub(:foo)
Notice the @
before the controller
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.