title: Using Capybara and Minitest to test JavaScript
body: <p>Several variations of this question have been asked, and I've definitely learned from reading up on the topic, but most of the answers didn't seem to be directly applicable to this situation, or involved solutions using Rspec or Cucumber.</p>
  
  <p>I'm currently working on a test suite using Minitest and Capybara. I don't want to have to bring in too many other gems if possible, but I'm open to it if they're lightweight, because tests are already taking a while to run.</p>
  
  <p>Rspec has <code>:js =&gt; true</code> and Cucumber has <code>@javascript</code>, but minitest doesn't seem to have anything like this. The natural solution, then, would be to switch drivers and do: <code>Capybara.current_driver = :selenium</code>, but when I do this, it doesn't work, and I get 2 errors (one for each of my js-enabled tests).</p>
  
  <p>My question is this: Why am I getting these errors, and how can I make some basic JavaScript testing work? Here's are the errors:</p>
  
  <pre><code>Component returned failure code: 0x804b0012 (NS_ERROR_UNKNOWN_PROTOCOL) [nsIWebNavigation.loadURI]
      Exception `Selenium::WebDriver::Error::UnknownError' at:
      /Users/epithelialbiology/.rvm/gems/ruby-1.9.2-p320/gems/selenium-webdriver-2.25.0/lib/selenium/webdriver/remote/response.rb:52:in `assert_ok'
      /Users/epithelialbiology/.rvm/gems/ruby-1.9.2-p320/gems/selenium-webdriver-2.25.0/lib/selenium/webdriver/remote/response.rb:15:in `initialize'
      /Users/epithelialbiology/.rvm/gems/ruby-1.9.2-p320/gems/selenium-webdriver-2.25.0/lib/selenium/webdriver/remote/http/common.rb:59:in `new'
      /Users/epithelialbiology/.rvm/gems/ruby-1.9.2-p320/gems/selenium-webdriver-2.25.0/lib/selenium/webdriver/remote/http/common.rb:59:in `create_response'
      /Users/epithelialbiology/.rvm/gems/ruby-1.9.2-p320/gems/selenium-webdriver-2.25.0/lib/selenium/webdriver/remote/http/default.rb:65:in `request'
      /Users/epithelialbiology/.rvm/gems/ruby-1.9.2-p320/gems/selenium-webdriver-2.25.0/lib/selenium/webdriver/remote/http/common.rb:40:in `call'
      /Users/epithelialbiology/.rvm/gems/ruby-1.9.2-p320/gems/selenium-webdriver-2.25.0/lib/selenium/webdriver/remote/bridge.rb:598:in `raw_execute'
      /Users/epithelialbiology/.rvm/gems/ruby-1.9.2-p320/gems/selenium-webdriver-2.25.0/lib/selenium/webdriver/remote/bridge.rb:576:in `execute'
      /Users/epithelialbiology/.rvm/gems/ruby-1.9.2-p320/gems/selenium-webdriver-2.25.0/lib/selenium/webdriver/remote/bridge.rb:99:in `get'
      /Users/epithelialbiology/.rvm/gems/ruby-1.9.2-p320/gems/selenium-webdriver-2.25.0/lib/selenium/webdriver/common/navigation.rb:14:in `to'
      /Users/epithelialbiology/.rvm/gems/ruby-1.9.2-p320/gems/capybara-1.1.2/lib/capybara/selenium/driver.rb:36:in `visit'
      /Users/epithelialbiology/.rvm/gems/ruby-1.9.2-p320/gems/capybara-1.1.2/lib/capybara/session.rb:157:in `visit'
      /Users/epithelialbiology/.rvm/gems/ruby-1.9.2-p320/gems/capybara-1.1.2/lib/capybara/dsl.rb:161:in `visit'
      test/integration/resource_access_test.rb:22:in `block (2 levels) in &lt;top (required)&gt;'
  </code></pre>
  
  <p>And here's the other error:</p>
  
  <pre><code>undefined method `[]' for nil:NilClass
      Exception `NoMethodError' at:
      /Users/epithelialbiology/.rvm/gems/ruby-1.9.2-p320/gems/rack-test-0.6.1/lib/rack/test.rb:171:in `env_for'
      /Users/epithelialbiology/.rvm/gems/ruby-1.9.2-p320/gems/rack-test-0.6.1/lib/rack/test.rb:56:in `get'
      /Users/epithelialbiology/.rvm/gems/ruby-1.9.2-p320/gems/capybara-1.1.2/lib/capybara/rack_test/browser.rb:62:in `process'
      /Users/epithelialbiology/.rvm/gems/ruby-1.9.2-p320/gems/capybara-1.1.2/lib/capybara/rack_test/browser.rb:21:in `visit'
      /Users/epithelialbiology/.rvm/gems/ruby-1.9.2-p320/gems/capybara-1.1.2/lib/capybara/rack_test/driver.rb:32:in `visit'
      /Users/epithelialbiology/.rvm/gems/ruby-1.9.2-p320/gems/capybara-1.1.2/lib/capybara/session.rb:157:in `visit'
      /Users/epithelialbiology/.rvm/gems/ruby-1.9.2-p320/gems/capybara-1.1.2/lib/capybara/dsl.rb:161:in `visit'
      test/integration/resource_access_test.rb:40:in `block (2 levels) in &lt;top (required)&gt;'
  </code></pre>
  
  <p>Does anyone know what could be going on here, as well as how I can fix this issue?</p>