黄瓜和/或 Webrat 讨厌  ?

发布于 2024-08-01 21:26:55 字数 545 浏览 3 评论 0原文

  添加到我的布局中时,我有一个黄瓜步骤最近开始失败。 如果我取出 ,我的测试就全部通过。 当我把它放回去时,每个使用 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''

有人有任何建议吗?

I have a cucumber step that recently started failing when an   was added to my layout. If I take the   out, my tests all pass. When I put it back in, every test that uses the click_link method supplied by WebRat fails with the following message:

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''

Does anyone have any suggestions?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

甜味拾荒者 2024-08-08 21:26:55

我在 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 票 260,但它对我不起作用,所以我不得不这样做以上。 希望这可以帮助。

I had the same problem under Ruby 1.9 and Rails 2.3.2, in order to get it working I had to make the following changes in the webrat gem.

In lib/webrat/core/locators/link_locator.rb I had to change:

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

to

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

There was also a patch submited to webrat Ticket 260, but it did not work for me so I had to do the above. Hope this helps.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文