问题
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