将 I18n 翻译添加到 rspec 测试 [英] Add I18n translations to rspec tests
本文介绍了将 I18n 翻译添加到 rspec 测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何将翻译测试添加到我的规范中?类似的东西:
How can i add a translation test to my specs ? Something like :
flash[:error].should == I18n.translate 'error.discovered'
这当然行不通.如何让它发挥作用?
this does not work of course. How to make it work ?
我想确保我得到某个错误.
I want to make sure that i get a certain error back.
推荐答案
在我的代码中,一个 Rails 3 项目,使用 RSpec 2,这正是我写的行:
In my code, a Rails 3 project, using RSpec 2, that is exactly the line I write:
describe "GET 'index'" do
before do
get 'index'
end
it "should be successful" do
response.should be_redirect
end
it "should show appropriate flash" do
flash[:warning].should == I18n.t('authorisation.not_authorized')
end
end
所以我不知道你为什么说这是不可能的?
So I am not sure why you say it is not possible?
这篇关于将 I18n 翻译添加到 rspec 测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文