ruby-on-rails – Cucumber用json编码失败:Encoding :: InvalidByteSequenceError

前端之家收集整理的这篇文章主要介绍了ruby-on-rails – Cucumber用json编码失败:Encoding :: InvalidByteSequenceError前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我使用的是rvm 1.15.6和 ruby-1.9.3-p194.

我创建了一个新的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",: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>'

我很神秘任何解决方案或建议进行故障排除?

编辑:这不是创建任何黄瓜功能文件.如果我创建功能文件,我得到相同的东西.

解决方法

我有同样的问题,它看起来是因为你的shell的编码

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

Linux的

export LANG=en_US.UTF-8

OS X

export LC_CTYPE=en_US.UTF-8
原文链接:https://www.f2er.com/ruby/266630.html

猜你在找的Ruby相关文章