ruby 1.9.2 运行 cucumber 规范时出现奇怪的警告

标签 ruby ruby-on-rails-3 cucumber rvm

我刚刚更新以试用 rails 3,将 rvm 与 ruby​​ 1.9.2-p0 结合使用。

当我运行我的 cucumber 规范时,我得到了以下奇怪的警告

/home/ubuntu/.rvm/gems/ruby-1.9.2-p0/gems/rack-1.2.1/lib/rack/utils.rb:16: warning: regexp match /.../n against to UTF-8 string

/home/ubuntu/.rvm/gems/ruby-1.9.2-p0/gems/rack-1.2.1/lib/rack/utils.rb:16: warning: regexp match /.../n against to UTF-8 string

/home/ubuntu/.rvm/gems/ruby-1.9.2-p0/gems/rack-1.2.1/lib/rack/utils.rb:16: warning: regexp match /.../n against to UTF-8 string

我的包中包含以下 gem...

Using rake (0.8.7) 
Using abstract (1.0.0) 
Using activesupport (3.0.0) 
Using builder (2.1.2) 
Using i18n (0.4.1) 
Using activemodel (3.0.0) 
Using erubis (2.6.6) 
Using rack (1.2.1) 
Using rack-mount (0.6.13) 
Using rack-test (0.5.4) 
Using tzinfo (0.3.23) 
Using actionpack (3.0.0) 
Using mime-types (1.16) 
Using polyglot (0.3.1) 
Using treetop (1.4.8) 
Using mail (2.2.5) 
Using actionmailer (3.0.0) 
Using arel (1.0.1) 
Using activerecord (3.0.0) 
Using activeresource (3.0.0) 
Using bundler (1.0.0) 
Using culerity (0.2.12) 
Using nokogiri (1.4.3.1) 
Using ffi (0.6.3) 
Using json_pure (1.4.6) 
Using rubyzip (0.9.4) 
Using selenium-webdriver (0.0.28) 
Using capybara (0.3.9) 
Using configuration (1.1.0) 
Using diff-lcs (1.1.2) 
Using trollop (1.16.2) 
Using gherkin (2.1.5) 
Using term-ansicolor (1.0.5) 
Using cucumber (0.8.5) 
Using cucumber-rails (0.3.2) 
Using database_cleaner (0.5.2) 
Using launchy (0.3.7) 
Using mysql2 (0.2.3) 
Using rspec-core (2.0.0.beta.20) 
Using rspec-expectations (2.0.0.beta.20) 
Using rspec-mocks (2.0.0.beta.20) 
Using rspec (2.0.0.beta.20) 
Using yard (0.6.0) 
Using pickle (0.4.2) 
Using thor (0.14.0) 
Using railties (3.0.0) 
Using rails (3.0.0) 
Using rspec-rails (2.0.0.beta.20) 
Using spork (0.8.4) 
Using webrat (0.7.1) 

有谁知道如何摆脱这些警告?他们来自哪里?

最佳答案

我在 Enrico Stahn 的博客文章中找到了一个很好的解决方案: http://blog.enricostahn.com/warning-regexp-match-n-against-to-utf-8-strin

问题出在 Rack 上,显然已经 been fixed在 1.3.0 中,但您可能无法升级到它。

因此,在您可以升级到 Rack 1.3.0 之前,使用以下内容创建文件 config/initializers/rack_hotfix.rb:

# TODO: Can be removed after updating to rack 1.3.0
module Rack
  module Utils
    def escape(s)
      CGI.escape(s.to_s)
    end
    def unescape(s)
      CGI.unescape(s)
    end
  end
end

这对我很有用,然后我通过对我的 RSpec 文件进行待定测试来补充它,作为一个温和的提醒,在 Rack 升级后删除初始化程序。

describe ApplicationController do
  ...
  it "should not include the rack_hotfix.rb initializer after upgrading to rack 1.3.0"

end

关于ruby 1.9.2 运行 cucumber 规范时出现奇怪的警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3622394/

相关文章:

ruby - 无法从下拉菜单项中单击元素

ruby-on-rails - 如何判断 Rails Action 邮件发送是否失败?

ruby - 缺少 Gem 依赖项

ruby - 获取 Ruby Cucumber 2.4 中的当前功能名称/描述?

ruby-on-rails - 使用 JRuby 进行 Rack 初始化时出错

ruby-on-rails - 如何在 Rails3 中使用子域作为参数?

ruby-on-rails-3 - Heroku 和 MongoHQ: ActionView::Template::Error (操作: #<Moped::Protocol::Commands::Authenticate 失败,错误 "auth fails")

cucumber - 如何读取 Karate 框架功能文件中的响应 header value ?

mysql - 值为数组的原始 sql。 ruby

ruby-on-rails - Rake 统计数据和 Cucumber