Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

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

Closed
aaronpark opened this Issue · 19 comments

9 participants

@aaronpark

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: 'https://github.com/jnicklas/capybara', :ref => 'd153635e6546ecc742e2b805390bc42a1e863d7c'

@jnicklas
Owner

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.

@itsNikolay

The same issue in my demo repository.
https://github.com/itsNikolay/error

visit "/users/sign_up" ### test's green https://github.com/itsNikolay/error/blob/master/spec/requests/user_pages_spec.rb
before{ visit new_admin_page_path } ### test's red https://github.com/itsNikolay/error/blob/master/spec/requests/page_request_spec.rb
............FF

Failures:

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

$> bundle show https://gist.github.com/3749185

This issue on Stackoverflow http://stackoverflow.com/questions/12485140/capybara-nomethoderror-undefined-method-visit-for/12489571#12489571

@joliss
Collaborator

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

@itsNikolay

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

@leesmith

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

@jnicklas
Owner

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
@leesmith

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

@felipeelias

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
@jnicklas
Owner

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

@sdhull

@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.

@jnicklas
Owner

@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.

@sdhull

@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.

@amritdeep

I am aso getting same error.

Error

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

Why is this thing happening ??

@jnicklas
Owner

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

@heaven

With :type => :feature I am getting:

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

and

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

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

@heaven

@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.