5

 がレイアウトに追加されたときに最近失敗し始めたキュウリのステップがあります。取り出せば 、私のテストはすべてパスします。戻すと、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''

誰か提案はありますか?

4

1 に答える 1

5

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に提出されたパッチもありましたが、うまくいかなかったため、上記を実行する必要がありました。お役に立てれば。

于 2009-08-12T19:45:00.267 に答える