I have just started using RSpec and I copied the very simple test on the RSpec github repo just to make sure things are working as expected:
require 'spec_helper'
describe 'Home Page' do
it "Welcomes the user" do
visit '/products'
page.should have_content("Welcome")
end
end
The problems begin when I change the string to something like "Olá" or "Caçamba". Any string with a special character. When I do that, I get the following error:
invalid multibyte char (US-ASCII) (SyntaxError)
invalid multibyte char (US-ASCII)
syntax error, unexpected $end, expecting ')'
page.should have_content("Olá")
Any ideas on how to fix it? Maybe some configuration option? Thanks a lot
Most likely you're missing a magic comment at the top of your file:
# encoding: UTF-8
Without this directive Ruby tries to interpret your file with the default US-ASCII encoding and fails since this character set does not include symbols like á
or ç
.
Here's a blog post on default source encoding in Ruby by James Edward Gray II.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With