International chars using RSpec with Ruby on Rails

前端 未结 2 1624
梦如初夏
梦如初夏 2021-02-14 00:24

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_helpe         


        
2条回答
  •  鱼传尺愫
    2021-02-14 00:53

    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.

提交回复
热议问题