page.should have_content - Special Characters causing error

末鹿安然 提交于 2019-12-12 13:53:15

问题


I am working on a basic Rspec test using Capybara that opens a webpage and checks that a string is contained within the home page. The tests require checking eaching of 8 different language sub domains on the sites and I have run into some problems with the special characters in the code.

The following code works:

it "should have an American Home page", :js => true do
  visit '/'
  page.should have_content('Workforce Management from InVision')
end

it "should have an English Home page", :js => true do
  visit '/uk/'
  page.should have_content('Workforce Management from InVision')
end

The following code DOES NOT WORK

it "should have a Spanish Home page at '/es/callcenter'", :js => true do
  visit '/es/'
  page.should have_content('Gestión de la plantilla con InVision')
end

I think that this is in relation to the ó in the word "Gestión". Any ideas how to stop this problem from occurring?


回答1:


Try adding # encoding: UTF-8 on the first line of the spec file.




回答2:


For me # coding UTF-8 worked. You may also try that.



来源:https://stackoverflow.com/questions/8819637/page-should-have-content-special-characters-causing-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!