我是 RSpec 的新手,我不知道如何测试以下内容:
在我的应用程序控制器(在 Rails 3 应用程序中)中,我在前置过滤器中设置区域设置,如下所示
def set_locale
I18n.locale = ["en", Setting.locale, get_locale_from_subdomain].compact.last
end
def get_locale_from_subdomain
locale = request.subdomain.split('.').first
return nil unless LOCALES.include? locale
locale
end
所以基本上,“en.example.com”和“example.com”将有一个“en”语言环境,而“fr.example.com”会将语言环境设置为“fr”。
我该如何测试呢?