warning: regexp match /…/n against to UTF-8 string error when using Cucumber

Ever since updating my environment to Rails 3.0.0 / RSpec 2.0.0.beta.20 / Cucumber 0.8.5 / Capybara 0.3.9 / Autotest 4.3.2, I’ve been getting the following error when Cucumber runs my features:

It seems that Rack is having a problem whenever UTF-8 strings are sent in the params. Thankfully, these guys found a solution.

For a more verbose description, check out that page. Here’s the quick and dirty:

Install the escape_utils gem by including this in your Gemfile:

Run bundle install to install the gem. Now, create a new file: RAILS_ROOT/config/initializers/escape_utils.rb with the following content:

And that should do it!

undefined method `visit’ for #<Cucumber::Rails::World:…> (NoMethodError)

I had the most obnoxious time troubleshooting this…advice varied wildly around the Internets. These were the applicable bits of my environment for my latest Ruby on Rails work (using Ruby 1.9.2p0 (2010-08-18 revision 29036) [x86_64-darwin10.4.0]):

I’d seen several other people had this same problem. Several of them solved the problem by changing the following in env.rb from:


This didn’t work for me, and I beat my head against the wall for hours trying to fix the problem. I finally created a new gemset, and rebuilt from scratch. This changed nothing. Then, I found this page. His instructions include a lot of unnecessary and outdated gems, though. So, followed his directions loosely–again with a fresh gemset–and did the following:

Reinstalled the latest Rails build:

Updated my Gemfile to:

Installed the bundled gems:

Checked what versions my dice roll had landed me with:

And got:

Finally, I installed autotest and friends:

And, voilá! I now have a fully-functional BDD development system again. The key? capybara. It seems that webrat just doesn’t play nicely with the latest Rails. Capybara is intended to be a drop-in replacement for webrat, and that it certainly is. BDD-away!

UPDATE: It seems that, as of 2.0.0.beta.20, RSpec and friends still require webrat (or need other configuring to work with Capybara–for which I don’t have time). Just add it to your Gemfile, bundle install, and away you go…