Skip to content


Subversion checkout URL

You can clone with
Download ZIP


undefined method `visit' for #<RSpec::Core::ExampleGroup #814

aaronpark opened this Issue · 19 comments

9 participants


ever since the september 7 commit de34c63 we have been getting these errors in our request specs.

If I set my gem file to the previous commit everything starts to works again. Just an FYI

:gem 'capybara', git: '', :ref => 'd153635e6546ecc742e2b805390bc42a1e863d7c'


This is kind of to be expected, see #809 for an ongoing discussion. More information about how to fix this will be upcoming and there will likely be a new release of RSpec at some point.


The same issue in my demo repository.

visit "/users/sign_up" ### test's green
before{ visit new_admin_page_path } ### test's red


1) Page pages page creation with invalid information should not create a page
     Failure/Error: before{ visit new_admin_page_path }
       undefined method `visit' for #<Page:0x00000005f47f90>
     # ./spec/requests/page_request_spec.rb:13:in `block (3 levels) in <top (required)>'

$> bundle show

This issue on Stackoverflow


@itsNikolay Yours is actually not the same error as this one - you're not on Capybara master. I'll leave an answer on SO.


@joliss There's no problem if you see solution. Will wait it on SO =)


I'm getting this error after updating to error when using beta2.


Relevant section:

Notably, we changed the :type that Capybara assumes your specs run under in RSpec to :feature (previously it was :request). The latest release of spec/features. Alternatively you can use the Capybara Feature DSL (feature instead of describe), which should work without any additional tweaking. If you see errors like undefined method visit, then you're probably encountering this issue. If you're including modules into :request specs, you will probably need to change that to :feature.

@jnicklas jnicklas closed this

Clearly I did not. I'm now subscribed to the google group. Thanks!


An additional thing I ran into:

Route helpers from RSpec are not being included into type: :feature so I had to add:

config.include RSpec::Rails::RequestExampleGroup, type: :feature

I think there are still problems with the rspec-rails implementation, I'm in contact with David Chelimsky, trying to work this out.


@leesmith thanks for the link to that blog post. Quite a bummer that Capybara upgraders were left in the lurch like this. In my situation, I had problems with my Gemfile.lock and had to remove it and re-bundle, which upgraded Capybara without me even wanting it to or thinking about it.

Just my opinion that there should be some sort of deprecation warning or explanation if a library suddenly stops working when you upgrade it. Sadly there wasn't. But your link to that blog post was (once I eventually found it) actually helpful. Too bad it wasn't included in deprecation warnings or something that would have been helpful to me (and surely others) when they (whether purposefully or not) upgrade Capybara and find nothing works anymore without any explanation or hint as to what went wrong.


@sdhull apologies that you had trouble with the upgrade. We try to follow semver, so we try to break compatibility very rarely. I would recommend adding a "~> 1.0" style dependency; as long as the major version number stays the same, we won't break compatibility in any way. We tried to document all changes as clearly as we could, both in the release announcement, and in the History file.

For most of the changes we made, a deprecation warning would have been impossible, but you're right that we probably could have added one in this case, somehow. We would have had to get rid of it pretty soon anyway though, since the whole point was to clean up clashes within a namespace. If we have to break compatibility again, I'll make sure we add warnings if is possible.


@jnicklas that would be really great. Personally would appreciate that consideration in the future, and I know probably all other devs using/upgrading Capybara would also appreciate it.


I am aso getting same error.


Git error: command git clone 'git://'
/.rvm/gems/ruby-1.9.2-p320/cache/bundler/git/capybara-f47214fa54f8dae1ca782e48ee86d54cdb2dc0b3" --bare --no-hardlinks
in directory

Why is this thing happening ??


@amritdeep how in the world is that the same error? That doesn't sound like it has anything to do with Capybara at all.


With :type => :feature I am getting:

undefined local variable or method `render_views' for RSpec::ExampleGroups::AdminImportController:Class (NameError)


undefined method `sign_in' for #<RSpec::ExampleGroups::AdminImportController::Import::WithSourceFileAttached:0x007fdac57611a8>

Capybara doesn't have either of those methods. I think you're looking in the wrong place.


@jnicklas thx, good to know.

I was commenting the proposed solution with :type => :feature. Btw, instead of adding that setting or replacing describe with feature I added:

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

to RSpec.configure and that solved everything in my case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.