title: unable to setup capybara in Rails
body: <p>I am learning how to do integration testing on a simple app in Rails using Capybara. </p>
  
  <p>However I got an error when running 'rspec spec':</p>
  
  <pre><code>bundle exec rspec spec
  /home/alex/.rvm/gems/ruby-2.0.0-p451@railstutorial_rails_4_0/gems/capybara-2.3.0/lib/capybara/dsl.rb:1: warning: loading in progress, circular require considered harmful - /home/alex/.rvm/gems/ruby-2.0.0-p451@railstutorial_rails_4_0/gems/capybara-2.3.0/lib/capybara.rb
      from /home/alex/.rvm/gems/ruby-2.0.0-p451@railstutorial_rails_4_0/bin/ruby_executable_hooks:15:in `&lt;main&gt;'
      from /home/alex/.rvm/gems/ruby-2.0.0-p451@railstutorial_rails_4_0/bin/ruby_executable_hooks:15:in `eval'
      from /home/alex/.rvm/gems/ruby-2.0.0-p451@railstutorial_rails_4_0/bin/rspec:23:in `&lt;main&gt;'
      from /home/alex/.rvm/gems/ruby-2.0.0-p451@railstutorial_rails_4_0/bin/rspec:23:in `load'
      from /home/alex/.rvm/gems/ruby-2.0.0-p451@railstutorial_rails_4_0/gems/rspec-core-3.0.0/exe/rspec:4:in `&lt;top (required)&gt;'
      from /home/alex/.rvm/gems/ruby-2.0.0-p451@railstutorial_rails_4_0/gems/rspec-core-3.0.0/lib/rspec/core/runner.rb:38:in `invoke'
      from /home/alex/.rvm/gems/ruby-2.0.0-p451@railstutorial_rails_4_0/gems/rspec-core-3.0.0/lib/rspec/core/runner.rb:70:in `run'
      from /home/alex/.rvm/gems/ruby-2.0.0-p451@railstutorial_rails_4_0/gems/rspec-core-3.0.0/lib/rspec/core/runner.rb:85:in `run'
      from /home/alex/.rvm/gems/ruby-2.0.0-p451@railstutorial_rails_4_0/gems/rspec-core-3.0.0/lib/rspec/core/runner.rb:96:in `setup'
      from /home/alex/.rvm/gems/ruby-2.0.0-p451@railstutorial_rails_4_0/gems/rspec-core-3.0.0/lib/rspec/core/configuration_options.rb:22:in `configure'
      from /home/alex/.rvm/gems/ruby-2.0.0-p451@railstutorial_rails_4_0/gems/rspec-core-3.0.0/lib/rspec/core/configuration_options.rb:100:in `process_options_into'
      from /home/alex/.rvm/gems/ruby-2.0.0-p451@railstutorial_rails_4_0/gems/rspec-core-3.0.0/lib/rspec/core/configuration_options.rb:100:in `each'
      from /home/alex/.rvm/gems/ruby-2.0.0-p451@railstutorial_rails_4_0/gems/rspec-core-3.0.0/lib/rspec/core/configuration_options.rb:101:in `block in process_options_into'
      from /home/alex/.rvm/gems/ruby-2.0.0-p451@railstutorial_rails_4_0/gems/rspec-core-3.0.0/lib/rspec/core/configuration.rb:1018:in `requires='
      from /home/alex/.rvm/gems/ruby-2.0.0-p451@railstutorial_rails_4_0/gems/rspec-core-3.0.0/lib/rspec/core/configuration.rb:1018:in `each'
      from /home/alex/.rvm/gems/ruby-2.0.0-p451@railstutorial_rails_4_0/gems/rspec-core-3.0.0/lib/rspec/core/configuration.rb:1018:in `block in requires='
      from /home/alex/.rvm/gems/ruby-2.0.0-p451@railstutorial_rails_4_0/gems/rspec-core-3.0.0/lib/rspec/core/configuration.rb:1018:in `require'
      from /home/alex/git-projects/rails-projects/qotd2/spec/spec_helper.rb:6:in `&lt;top (required)&gt;'
      from /home/alex/git-projects/rails-projects/qotd2/spec/spec_helper.rb:6:in `require'
      from /home/alex/.rvm/gems/ruby-2.0.0-p451@railstutorial_rails_4_0/gems/capybara-2.3.0/lib/capybara/rails.rb:1:in `&lt;top (required)&gt;'
      from /home/alex/.rvm/gems/ruby-2.0.0-p451@railstutorial_rails_4_0/gems/capybara-2.3.0/lib/capybara/rails.rb:1:in `require'
      from /home/alex/.rvm/gems/ruby-2.0.0-p451@railstutorial_rails_4_0/gems/capybara-2.3.0/lib/capybara.rb:5:in `&lt;top (required)&gt;'
      from /home/alex/.rvm/gems/ruby-2.0.0-p451@railstutorial_rails_4_0/gems/capybara-2.3.0/lib/capybara.rb:320:in `&lt;module:Capybara&gt;'
      from /home/alex/.rvm/gems/ruby-2.0.0-p451@railstutorial_rails_4_0/gems/capybara-2.3.0/lib/capybara.rb:320:in `require'
      from /home/alex/.rvm/gems/ruby-2.0.0-p451@railstutorial_rails_4_0/gems/capybara-2.3.0/lib/capybara/dsl.rb:1:in `&lt;top (required)&gt;'
      from /home/alex/.rvm/gems/ruby-2.0.0-p451@railstutorial_rails_4_0/gems/capybara-2.3.0/lib/capybara/dsl.rb:1:in `require'
  /home/alex/.rvm/gems/ruby-2.0.0-p451@railstutorial_rails_4_0/gems/capybara-2.3.0/lib/capybara/node/matchers.rb:121: warning: assigned but unused variable - e
  /home/alex/.rvm/gems/ruby-2.0.0-p451@railstutorial_rails_4_0/gems/capybara-2.3.0/lib/capybara/selenium/driver.rb:119: warning: assigned but unused variable - a
  /home/alex/.rvm/gems/ruby-2.0.0-p451@railstutorial_rails_4_0/gems/capybara-2.3.0/lib/capybara/rails.rb:6:in `block (2 levels) in &lt;top (required)&gt;': uninitialized constant Rails (NameError)
      from /home/alex/.rvm/gems/ruby-2.0.0-p451@railstutorial_rails_4_0/gems/rack-1.5.2/lib/rack/builder.rb:55:in `instance_eval'
      from /home/alex/.rvm/gems/ruby-2.0.0-p451@railstutorial_rails_4_0/gems/rack-1.5.2/lib/rack/builder.rb:55:in `initialize'
      from /home/alex/.rvm/gems/ruby-2.0.0-p451@railstutorial_rails_4_0/gems/rack-1.5.2/lib/rack/builder.rb:145:in `new'
      from /home/alex/.rvm/gems/ruby-2.0.0-p451@railstutorial_rails_4_0/gems/rack-1.5.2/lib/rack/builder.rb:145:in `block in generate_map'
      from /home/alex/.rvm/gems/ruby-2.0.0-p451@railstutorial_rails_4_0/gems/rack-1.5.2/lib/rack/builder.rb:145:in `each'
      from /home/alex/.rvm/gems/ruby-2.0.0-p451@railstutorial_rails_4_0/gems/rack-1.5.2/lib/rack/builder.rb:145:in `generate_map'
      from /home/alex/.rvm/gems/ruby-2.0.0-p451@railstutorial_rails_4_0/gems/rack-1.5.2/lib/rack/builder.rb:132:in `to_app'
      from /home/alex/.rvm/gems/ruby-2.0.0-p451@railstutorial_rails_4_0/gems/capybara-2.3.0/lib/capybara/rails.rb:13:in `&lt;top (required)&gt;'
      from /home/alex/git-projects/rails-projects/qotd2/spec/spec_helper.rb:6:in `require'
      from /home/alex/git-projects/rails-projects/qotd2/spec/spec_helper.rb:6:in `&lt;top (required)&gt;'
      from /home/alex/.rvm/gems/ruby-2.0.0-p451@railstutorial_rails_4_0/gems/rspec-core-3.0.0/lib/rspec/core/configuration.rb:1018:in `require'
      from /home/alex/.rvm/gems/ruby-2.0.0-p451@railstutorial_rails_4_0/gems/rspec-core-3.0.0/lib/rspec/core/configuration.rb:1018:in `block in requires='
      from /home/alex/.rvm/gems/ruby-2.0.0-p451@railstutorial_rails_4_0/gems/rspec-core-3.0.0/lib/rspec/core/configuration.rb:1018:in `each'
      from /home/alex/.rvm/gems/ruby-2.0.0-p451@railstutorial_rails_4_0/gems/rspec-core-3.0.0/lib/rspec/core/configuration.rb:1018:in `requires='
      from /home/alex/.rvm/gems/ruby-2.0.0-p451@railstutorial_rails_4_0/gems/rspec-core-3.0.0/lib/rspec/core/configuration_options.rb:101:in `block in process_options_into'
      from /home/alex/.rvm/gems/ruby-2.0.0-p451@railstutorial_rails_4_0/gems/rspec-core-3.0.0/lib/rspec/core/configuration_options.rb:100:in `each'
      from /home/alex/.rvm/gems/ruby-2.0.0-p451@railstutorial_rails_4_0/gems/rspec-core-3.0.0/lib/rspec/core/configuration_options.rb:100:in `process_options_into'
      from /home/alex/.rvm/gems/ruby-2.0.0-p451@railstutorial_rails_4_0/gems/rspec-core-3.0.0/lib/rspec/core/configuration_options.rb:22:in `configure'
      from /home/alex/.rvm/gems/ruby-2.0.0-p451@railstutorial_rails_4_0/gems/rspec-core-3.0.0/lib/rspec/core/runner.rb:96:in `setup'
      from /home/alex/.rvm/gems/ruby-2.0.0-p451@railstutorial_rails_4_0/gems/rspec-core-3.0.0/lib/rspec/core/runner.rb:85:in `run'
      from /home/alex/.rvm/gems/ruby-2.0.0-p451@railstutorial_rails_4_0/gems/rspec-core-3.0.0/lib/rspec/core/runner.rb:70:in `run'
      from /home/alex/.rvm/gems/ruby-2.0.0-p451@railstutorial_rails_4_0/gems/rspec-core-3.0.0/lib/rspec/core/runner.rb:38:in `invoke'
      from /home/alex/.rvm/gems/ruby-2.0.0-p451@railstutorial_rails_4_0/gems/rspec-core-3.0.0/exe/rspec:4:in `&lt;top (required)&gt;'
      from /home/alex/.rvm/gems/ruby-2.0.0-p451@railstutorial_rails_4_0/bin/rspec:23:in `load'
      from /home/alex/.rvm/gems/ruby-2.0.0-p451@railstutorial_rails_4_0/bin/rspec:23:in `&lt;main&gt;'
      from /home/alex/.rvm/gems/ruby-2.0.0-p451@railstutorial_rails_4_0/bin/ruby_executable_hooks:15:in `eval'
      from /home/alex/.rvm/gems/ruby-2.0.0-p451@railstutorial_rails_4_0/bin/ruby_executable_hooks:15:in `&lt;main&gt;'
  </code></pre>
  
  <p>My Gemfile (partial):</p>
  
  <pre><code>group :test do
      gem 'fake'
      gem 'capybara'
      gem 'database_cleaner'
      gem 'launchy'
  end
  
  group :development, :test do
      gem 'rspec-rails'
      gem 'factory_girl_rails'
      gem 'guard-rspec'
      gem 'growl'
      gem 'dotenv-rails'
  end
  </code></pre>
  
  <p>My test case <code>(location: /spec/features/users_spec.rb)</code>:</p>
  
  <pre><code>require 'spec_helper'
  
  describe 'User authentication' do 
      context 'new user signs up' do
          it "saves the new user" do 
              visit "/"
              expect {
                  click_button 'Sign up'
                  fill_in 'Name', with: 'alexjiao'
                  fill_in 'Email', with: "alexjiao@yahoo.com"
                  fill_in 'Password', with: 'asdfasdf'
                  fill_in 'Password confirmation', with: 'asdfasdf'
                  click_button 'Create my account'
              }.to change(User, :count).by(1)
          end
      end
  
  end
  </code></pre>
  
  <p>My spec_helper.rb <code>(location: /spec/spec_helper.rb)</code>:</p>
  
  <pre><code>require 'capybara/rails'
  require 'capybara/rspec'
  
  RSpec.configure do |config|
    config.include Capybara::DSL
  end
  </code></pre>
  
  <p>Several solutions such as putting test case in features folder and creating a config statement for capybara DSL are all here. But I can't seem to get capybara working. Seems that my situation is a bit unique especially with the error message above. One thing to take note of is that after running <code>rails g rspec:install</code>, my <code>spec_helper.rb</code> is empty (is that normal?). Hence this accounts for its terse code above.</p>
  
  <p>Any thoughts?</p>