我有一个黄瓜步骤,当一个 添加到我的布局中时,这个步骤最近开始失败。如果我把 拿出来,我的测试都通过了。当我将它放回原处时,每个使用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''有人有什么建议吗?
发布于 2009-08-12 19:45:00
我在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,但它对我不起作用,所以我不得不这么做。希望这能有所帮助。
https://stackoverflow.com/questions/1268094
复制相似问题