我試圖寫在我的Rails應用程序的一些功能測試,並在application_controller.rb我有這樣的:如何在Rails中存根或模擬request.subdomains方法?
before_filter :current_account
def current_account
@current_account ||= Account.find_by_subdomain!(request.subdomians.first)
end
在運行測試,request.subdomains
不包含我在尋找有效的子域和使得不可能運行任何功能測試。
是否有可能存根current_account
方法或模擬request.subdomains
對象?