Rspec have_link 带有重音词

发布于 2025-01-06 20:54:05 字数 889 浏览 5 评论 0原文

有谁经历过这种测试吗?

这样做:

# 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

半透明的墙 2025-01-13 20:54:06

一种方法是将:

# encoding: utf-8

放在规范文件的顶部,以便 Ruby 知道该文件包含非 ASCII 字符。

更多信息:http://nuclearsquid.com/writings/ruby-1-9-encodings /

One way would be to put:

# encoding: utf-8

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/

稀香 2025-01-13 20:54:06

您的来源是否指定脚本中包含 Unicode?

# encoding: UTF-8 

这是一篇非常好的文章: 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?

# encoding: UTF-8 

Here is a really good writeup: http://yehudakatz.com/2010/05/05/ruby-1-9-encodings-a-primer-and-the-solution-for-rails/

南渊 2025-01-13 20:54:06

固定的。

有一瞬间我忘记了我是在 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文