Search code examples
ruby-on-railsrspeccapybararuby-on-rails-2

Setting up Capybara for Rails 2.3 and Rspec


I'm having some trouble setting up capybara (0.4.1.2) in a rails 2.3.8 app with Rspec 1.3 From the installation capybara instructions, I've inserted the line:

require 'capybara/rspec' 

However that gives me a missing constant error. Seems like it's looking for a class 'RSpec' which isn't loaded (I'm guessing that's an RSpec 2 / Rails 3 thing).

So how do I get Rspec to recognize capybara under rails 2.3? Should I use an earlier version of capy?

PS. Here's a snippet of the backtrace:

/Users/rafe/.rvm/gems/ruby-1.8.6-p399@lci/gems/activesupport-2.3.5/lib/active_support/dependencies.rb|443| in `load_missing_constant': uninitialized constant RSpec (NameError)

/Users/rafe/.rvm/gems/ruby-1.8.6-p399@lci/gems/activesupport-2.3.5/lib/active_support/dependencies.rb|80| in `const_missing_not_from_s3_library'

/Users/rafe/.rvm/gems/ruby-1.8.6-p399@lci/gems/aws-s3-0.6.2/lib/aws/s3/extensions.rb|206| in `const_missing'

/Users/rafe/.rvm/gems/ruby-1.8.6-p399@lci/gems/activesupport-2.3.5/lib/active_support/dependencies.rb|92| in `const_missing'

||  from /Users/rafe/.rvm/gems/ruby-1.8.6-p399@lci/gems/capybara-0.4.1.2/lib/capybara/rspec.rb:4


/Users/rafe/.rvm/gems/ruby-1.8.6-p399@lci/gems/rails-2.3.5/lib/rails/gem_dependency.rb|119| Warning: Gem::Dependency#version_requirements is deprecated and will be removed on or after August 2010.  Use #requirement

/Users/rafe/.rvm/gems/ruby-1.8.6-p399@lci/gems/activesupport-2.3.5/lib/active_support/dependencies.rb|443| in `load_missing_constant': uninitialized constant RSpec (NameError)

/Users/rafe/.rvm/gems/ruby-1.8.6-p399@lci/gems/activesupport-2.3.5/lib/active_support/dependencies.rb|80| in `const_missing_not_from_s3_library'

/Users/rafe/.rvm/gems/ruby-1.8.6-p399@lci/gems/aws-s3-0.6.2/lib/aws/s3/extensions.rb|206| in `const_missing'

/Users/rafe/.rvm/gems/ruby-1.8.6-p399@lci/gems/activesupport-2.3.5/lib/active_support/dependencies.rb|92| in `const_missing'

|   from /Users/rafe/.rvm/gems/ruby-1.8.6-p399@lci/gems/capybara-0.4.1.2/lib/capybara/rspec.rb:4

/Users/rafe/.rvm/rubies/ruby-1.8.6-p399/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb|31| in `gem_original_require'

/Users/rafe/.rvm/rubies/ruby-1.8.6-p399/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb|31| in `require'

/Users/rafe/.rvm/gems/ruby-1.8.6-p399@lci/gems/activesupport-2.3.5/lib/active_support/dependencies.rb|158| in `require'

||  from /Users/rafe/cmi/lci/branches/forums/spec/spec_helper.rb:12

Solution

  • Capybara does not have built in support for RSpec 1.x. However, you can use Steak instead of rolling your own RSpec support.