【发布时间】:2009-11-13 10:44:47
【问题描述】:
我想确保我的视图中有正确的元描述/关键字和标题文本,因此我想为此创建 rspec 视图测试。现在真正的挑战是如何让它跨多种语言工作。
我的做法是:
it "should have the right page title" do
title = "some nice title here"
response.should have_tag("title", title)
end
因此,由于该示例中的“要求”是硬编码的,因此我很难弄清楚如何对我的 config/locale/ 中的所有其他语言执行相同的操作。
我不确定这是否是最好的方法,或者我应该像这样从 locale/lang.yml 获取文本:
it "should have the right page title" do
title = t('site.title')
response.should have_tag("title", title)
end
谢谢
【问题讨论】:
标签: ruby-on-rails unit-testing testing rspec cucumber