We at Codelearn use Capybara and Rspec-rails for all our integration tests. More than that we use Capybara for testing all the apps written by users, to check if the apps have any errors wrt functionality.

So If you are curious, how the “Run Tests” magically figures out if your apps are right, the credit goes to Capybara and Rspec-rails.



However, recently Capybara launched its latest version 2.0 , and all hell broke loose. As you would see below, our users started getting an error, undefined method ‘visit’ .



We explored different ways to solve this issue. The most straightforward way, is to downgrade Capybara to version 1.1.2. This would involve changing every users’ Gemfile to include the following line with the version number of Capybara as 1.1.2. However this is a crude way.


gem "capybara", '1.1.2', :group => "test"


This change did solve the problem but this is not a clean way to solve the problem. After some exploration we figured that some things had changed with Capybara 2.0.

In Capybara 2.0, if you use ‘visit’ method in your integration tests, move your integration tests (spec files)  to features directory from requests directory, where it used to be placed previously. So when we moved our integration tests (the one containing ‘visit’ method) from the requests directory to features directory, there was no error.

To summarize, So if you are upgrading to Capybara 2.0 from your current version, you will end up with undefined method ’visit’ error. You need to move your integration test files from requests directory to features directory.


rspec-rails and capybara 2.0: what you need to know
Capybara 2.0 Upgrade Guide
Learn Android by creating a twitter app. Visit http://www.codelearn.org/android-tutorial/.
  • Tejaswi Rana

    There’s another way to do this… in the Rspec helper class, just add config telling you want to use Capybara like below:

    config.include Capybara::DSL, :type => :request

    this is a lot cleaner approach.

    • Yoann Celton

      Works fine, and definitly cleaner. Thanks!