2
当与RSpec中的I18n的翻译测试Ruby代码,我得到的错误是这样的:如何测试用的I18n翻译Ruby代码中的RSpec
translation missing: en.lib.filter.equal_to
这里有一个简单的例子:
def word_for_operator
I18n.t('lib.filter.equal_to')
end
规格:
it "returns the correct label" do
expect(filter.word_for_operator).to eq("some value")
end
在Rails中一切正常。
如何在我的规格中使用I18n?
不知道我是否理解你的问题。你是说你有一个有效的':en'语言环境,但RSpec没有使用它? – Stefan
@Stefan是的,这是正确的。它可以在使用Rails应用程序作为宝石时运行,或者独立运行,但不在规范中运行。 – Steve