Rspec have_link 带有重音词
有谁经历过这种测试吗?
这样做:
# this works
it { should have_link("Next") }
但使用包含“Próximo”(葡萄牙语中的“Next”)等重音符号的单词进行相同的测试
# it fails
it { should have_link("Próximo") }
错误:
1) UserPages index pagination
Failure/Error: it { should have_link("Próximo") }
expected link "Próximo" to return something
# ./spec/requests/user_pages_spec.rb:29:in `block (4 levels) in <top (required)>'
Finished in 2.8 seconds
28 examples, 1 failure
user_pages_spec.rb(仅相关代码)
describe "pagination" do
before(:all) { 30.times { FactoryGirl.create(:user) } }
after(:all) { User.delete_all }
it { should_not have_link('delete') }
it { should have_link("Próximo") }
it { should have_link('2') }
end
应该如何我做这个测试?
Anyone experienced this kind of test?
Doing this:
# this works
it { should have_link("Next") }
but the same test using a word that contain accents like "Próximo" (means Next in portuguese)
# it fails
it { should have_link("Próximo") }
error:
1) UserPages index pagination
Failure/Error: it { should have_link("Próximo") }
expected link "Próximo" to return something
# ./spec/requests/user_pages_spec.rb:29:in `block (4 levels) in <top (required)>'
Finished in 2.8 seconds
28 examples, 1 failure
user_pages_spec.rb (only the relevant code)
describe "pagination" do
before(:all) { 30.times { FactoryGirl.create(:user) } }
after(:all) { User.delete_all }
it { should_not have_link('delete') }
it { should have_link("Próximo") }
it { should have_link('2') }
end
How should I do this test?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
一种方法是将:
放在规范文件的顶部,以便 Ruby 知道该文件包含非 ASCII 字符。
更多信息:http://nuclearsquid.com/writings/ruby-1-9-encodings /
One way would be to put:
at the top of your spec file so Ruby knows the file contains non-ASCII characters.
more info: http://nuclearsquid.com/writings/ruby-1-9-encodings/
您的来源是否指定脚本中包含 Unicode?
这是一篇非常好的文章: http://yehudakatz.com/2010/05/05/ruby-1-9-encodings-a-primer-and-the-solution-for-rails/
Does your source specify that the script has Unicode in it?
Here is a really good writeup: http://yehudakatz.com/2010/05/05/ruby-1-9-encodings-a-primer-and-the-solution-for-rails/
固定的。
有一瞬间我忘记了我是在 Spork 下运行的,我所要做的就是重新启动网络服务器并重新启动 Spork。
提示:如果您正在运行 Nginx,请转到控制台并在项目文件夹下输入
touch tmp/restart.txt
。它将重新启动 Nginx。Fixed.
For a moment I forgot that I was running under Spork and all I have to do was restart the webserver and restart the Spork as well.
Tip: If you are running Nginx, go to console and type
touch tmp/restart.txt
under your project folder. It will restart the Nginx.