page.should have_content - Special Characters caus

2019-07-04 11:49发布

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?

2条回答
手持菜刀,她持情操
2楼-- · 2019-07-04 12:14

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

查看更多
Juvenile、少年°
3楼-- · 2019-07-04 12:27

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

查看更多
登录 后发表回答