【问题标题】:Cucumber and/or Webrat hates  ?Cucumber 和/或 Webrat 讨厌?
【发布时间】:2010-11-19 01:54:47
【问题描述】:

  被添加到我的布局时,我有一个黄瓜步骤最近开始失败。如果我把  拿出来,我的测试都会通过。当我把它放回去时,使用 WebRat 提供的 click_link 方法的每个测试都会失败并显示以下消息:

And he follows 'Unsubscribe'
  incompatible encoding regexp match (UTF-8 regexp with ASCII-8BIT string) (Encoding::CompatibilityError)
  (eval):3:in `click_link`
  (eval):2:in `click_link`
  /path_to_project/webrat_steps.rb:19:in `/^(I|he|she) follows? '([^\"]*)'$/'
  features/manage_subscriptions.feature:59:in `And he follows 'Unsubscribe''

有人有什么建议吗?

【问题讨论】:

    标签: ruby-on-rails cucumber webrat


    【解决方案1】:

    我在 Ruby 1.9 和 Rails 2.3.2 下遇到了同样的问题,为了让它工作,我必须在 webrat gem 中进行以下更改。

    lib/webrat/core/locators/link_locator.rb我不得不改变:

    def replace_nbsp(str)
      str.gsub([0xA0].pack('U'), ' ')
    end
    

    def replace_nbsp(str)
      if str.respond_to?(:valid_encoding?)
        str.force_encoding('UTF-8').gsub(/\xc2\xa0/u, ' ')
      else
        str.gsub(/\xc2\xa0/u, ' ')
      end
    end
    

    还有一个补丁提交给 webrat Ticket 260,但它对我不起作用,所以我不得不执行上述操作。希望这会有所帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-05-07
      • 2010-11-25
      • 1970-01-01
      • 1970-01-01
      • 2018-04-18
      • 1970-01-01
      • 2011-02-02
      相关资源
      最近更新 更多