Cucumber and / or Webrat hates & nbsp ;?

I have a cucumber pitch that recently started crashing when it was added to my layout  . If I choose  , my tests will pass. When I get it back, every test using the click_link method provided by WebRat will produce 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?

+5
source share
1 answer

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

As lib/webrat/core/locators/link_locator.rbI 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

, webrat Ticket 260, , . , .

+5

All Articles