I''m testing a Rails 3 app with Rspec and Capybara. For my integration tests, I need to test javascript. Of course, I watched http://railscasts.com/episodes/257-request-specs-and-capybara which presents the basics very well. Unfortunately an error is raised in the javascript as I can see using save_and_open_page It seems characters are encoded by Capybara or Selenium so this js loop crashes because of the <: <script charset="utf-8" type="text/javascript"> //code here for (var i = 0; i < lines.length; ++i) { //...stuff here } //code here </script> Reason: Uncaught SyntaxError: Unexpected token ; I did put: <meta http-equiv="content-type" content="text/html; charset=utf-8" /> in my head so I can''t understand the problem.