9

我正在使用 rvm 1.15.6 和 ruby​​-1.9.3-p194。

我使用以下 gem 创建了一个新的 Rails 应用程序:

source 'https://rubygems.org'
gem 'rails', '3.2.8'
gem 'sqlite3'
group :assets do
  gem 'sass-rails',   '~> 3.2.3'
  gem 'coffee-rails', '~> 3.2.1'
  gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
gem "rspec-rails", ">= 2.10.1", :group => [:development, :test]
gem "factory_girl_rails", ">= 3.3.0", :group => [:development, :test]
gem "cucumber-rails", ">= 1.3.0", :group => :test, :require => false
gem "capybara", ">= 1.1.2", :group => :test
gem "database_cleaner", ">= 0.7.2", :group => :test

当我运行时:

bundle exec cucumber

我收到一个错误:

json-1.7.5/lib/json/common.rb:155:in `encode': "\xD8" on US-ASCII (Encoding::InvalidByteSequenceError)

这是完整的跟踪:

/Users/danielkehoe/.rvm/gems/ruby-1.9.3-p194@rails328/gems/json-1.7.5/lib/json/common.rb:155:in `encode': "\xD8" on US-ASCII (Encoding::InvalidByteSequenceError)
    from /Users/danielkehoe/.rvm/gems/ruby-1.9.3-p194@rails328/gems/json-1.7.5/lib/json/common.rb:155:in `initialize'
    from /Users/danielkehoe/.rvm/gems/ruby-1.9.3-p194@rails328/gems/json-1.7.5/lib/json/common.rb:155:in `new'
    from /Users/danielkehoe/.rvm/gems/ruby-1.9.3-p194@rails328/gems/json-1.7.5/lib/json/common.rb:155:in `parse'
    from /Users/danielkehoe/.rvm/gems/ruby-1.9.3-p194@rails328/gems/gherkin-2.11.2/lib/gherkin/i18n.rb:14:in `<class:I18n>'
    from /Users/danielkehoe/.rvm/gems/ruby-1.9.3-p194@rails328/gems/gherkin-2.11.2/lib/gherkin/i18n.rb:6:in `<module:Gherkin>'
    from /Users/danielkehoe/.rvm/gems/ruby-1.9.3-p194@rails328/gems/gherkin-2.11.2/lib/gherkin/i18n.rb:5:in `<top (required)>'
    from /Users/danielkehoe/.rvm/gems/ruby-1.9.3-p194@rails328/gems/gherkin-2.11.2/lib/gherkin/lexer/i18n_lexer.rb:1:in `require'
    from /Users/danielkehoe/.rvm/gems/ruby-1.9.3-p194@rails328/gems/gherkin-2.11.2/lib/gherkin/lexer/i18n_lexer.rb:1:in `<top (required)>'
    from /Users/danielkehoe/.rvm/gems/ruby-1.9.3-p194@rails328/gems/gherkin-2.11.2/lib/gherkin.rb:1:in `require'
    from /Users/danielkehoe/.rvm/gems/ruby-1.9.3-p194@rails328/gems/gherkin-2.11.2/lib/gherkin.rb:1:in `<top (required)>'
    from /Users/danielkehoe/.rvm/gems/ruby-1.9.3-p194@rails328/gems/cucumber-1.2.1/lib/cucumber/cli/main.rb:2:in `require'
    from /Users/danielkehoe/.rvm/gems/ruby-1.9.3-p194@rails328/gems/cucumber-1.2.1/lib/cucumber/cli/main.rb:2:in `<top (required)>'
    from /Users/danielkehoe/.rvm/gems/ruby-1.9.3-p194@rails328/gems/cucumber-1.2.1/bin/cucumber:11:in `require'
    from /Users/danielkehoe/.rvm/gems/ruby-1.9.3-p194@rails328/gems/cucumber-1.2.1/bin/cucumber:11:in `<top (required)>'
    from /Users/danielkehoe/.rvm/gems/ruby-1.9.3-p194@rails328/bin/cucumber:19:in `load'
    from /Users/danielkehoe/.rvm/gems/ruby-1.9.3-p194@rails328/bin/cucumber:19:in `<main>'
    from /Users/danielkehoe/.rvm/gems/ruby-1.9.3-p194@rails328/bin/ruby_noexec_wrapper:14:in `eval'
    from /Users/danielkehoe/.rvm/gems/ruby-1.9.3-p194@rails328/bin/ruby_noexec_wrapper:14:in `<main>'

我很迷惑。有什么解决方案或故障排除建议吗?

编辑:这没有创建任何 Cucumber 功能文件。如果我创建功能文件,我会得到同样的结果。

4

1 回答 1

24

我遇到了同样的问题,看起来是因为你的shell的编码

看看这个页面https://github.com/cucumber/gherkin

Linux

export LANG=en_US.UTF-8

操作系统

export LC_CTYPE=en_US.UTF-8
于 2012-08-26T19:30:54.043 回答