【发布时间】:2016-04-17 12:44:33
【问题描述】:
我的应用程序控制器如下所示:
class ApplicationController
before_action :set_customer
def customer?
@customer.nil?
end
private
def set_customer
if request.host != "example.com"
@customer = Customer.find_by_domain("...")
else
if request.subdomain != "www"
@customer = Customer.find_by_sub("...")
end
end
end
end
如何对 ApplicationController 进行测试?
我想传入 URL,然后检查 @customer 是否为 nil 等。
例如要测试的 URLs
example.com
www.example.com
google.com
hello.example.com
【问题讨论】:
标签: ruby-on-rails rspec