Note that there are some explanatory texts on larger screens.

plurals
  1. POUndefined method 'visit' (using rspec and capybara)
    primarykey
    data
    text
    <p>Upon trying to run a specs files for integration testing, I see:</p> <pre><code>undefined method `visit' for #&lt;Class:0xab9a140&gt; (NoMethodError) </code></pre> <p>I've searched this website and found out several solutions to my problems, and these are the <strong>solutions I've tried already</strong> ( with no success ):</p> <ul> <li>added file under spec/features instead of spec/requests (they have always been there)</li> <li><p>add <code>include Capybara::DSL</code> to my spec file - this is funny. When I add this, I stop having the aforementioned error and start having <strong>another error message</strong>: </p> <ul> <li><code>undefined method 'expect' for #&lt;Class:0x9d2a088&gt; (NoMethodError)</code></li> </ul></li> <li>replacing <code>describe</code> with <code>feature</code> in the spec tests. (no change)</li> </ul> <p>Outcome of trying to run the specs which contain the <code>visit</code> method:</p> <pre><code>felipe@felipe-VirtualBox:~/rails/project-manager$ bundle exec rspec spec/features/ No DRb server is running. Running in local process instead ... /home/felipe/rails/project-manager/spec/features/projects_spec.rb:15:in `block (2 levels) in &lt;top (required)&gt;': undefined method `visit' for #&lt;Class:0xab9a140&gt; (NoMethodError) from /home/felipe/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.7/lib/rspec/core/example_group.rb:246:in `module_eval' from /home/felipe/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.7/lib/rspec/core/example_group.rb:246:in `subclass' from /home/felipe/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.7/lib/rspec/core/example_group.rb:232:in `describe' from /home/felipe/rails/project-manager/spec/features/projects_spec.rb:14:in `block in &lt;top (required)&gt;' from /home/felipe/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.7/lib/rspec/core/example_group.rb:246:in `module_eval' from /home/felipe/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.7/lib/rspec/core/example_group.rb:246:in `subclass' from /home/felipe/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.7/lib/rspec/core/example_group.rb:232:in `describe' from /home/felipe/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.7/lib/rspec/core/dsl.rb:18:in `describe' from /home/felipe/rails/project-manager/spec/features/projects_spec.rb:3:in `&lt;top (required)&gt;' from /home/felipe/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.7/lib/rspec/core/configuration.rb:896:in `load' from /home/felipe/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.7/lib/rspec/core/configuration.rb:896:in `block in load_spec_files' from /home/felipe/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.7/lib/rspec/core/configuration.rb:896:in `each' from /home/felipe/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.7/lib/rspec/core/configuration.rb:896:in `load_spec_files' from /home/felipe/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.7/lib/rspec/core/command_line.rb:22:in `run' from /home/felipe/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.7/lib/rspec/core/runner.rb:77:in `rescue in run' from /home/felipe/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.7/lib/rspec/core/runner.rb:73:in `run' from /home/felipe/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.7/lib/rspec/core/runner.rb:17:in `block in autorun' </code></pre> <p><strong>my Gemfile:</strong></p> <pre><code>source 'https://rubygems.org' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '4.0.1' group :development,:test do gem 'rspec-rails' gem 'pg','0.15.1' gem 'watchr' gem 'selenium-webdriver' gem 'capybara' gem 'spork-rails' gem 'guard-spork' gem 'childprocess' end gem 'sass-rails', '~&gt; 4.0.1' gem 'uglifier', '&gt;= 2.1.0' gem 'coffee-rails', '~&gt; 4.0.1' gem 'jquery-rails','3.0.4' gem 'turbolinks','1.1.1' gem 'jbuilder', '~&gt; 1.2' group :doc do # bundle exec rake doc:rails generates the API under doc/api. gem 'sdoc', require: false end </code></pre> <p><strong>My spec_helper.rb file</strong></p> <pre><code>require 'rubygems' require 'spork' Spork.prefork do ENV["RAILS_ENV"] ||= 'test' require File.expand_path("../../config/environment", __FILE__) require 'rspec/rails' require 'rspec/autorun' Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f} ActiveRecord::Migration.check_pending! if defined?(ActiveRecord::Migration) RSpec.configure do |config| config.fixture_path = "#{::Rails.root}/spec/fixtures" config.use_transactional_fixtures = true config.infer_base_class_for_anonymous_controllers = false config.order = "random" # Disable the old-style object.should syntax. config.expect_with :rspec do |c| c.syntax = :expect end end end Spork.each_run do end </code></pre> <p><strong>the actual test (yes, it's under <code>spec/features</code> folder)</strong></p> <pre><code>require 'spec_helper' describe "Projects" do describe "Projects index" do it "should show the string 'Projetos'" do visit '/projects' expect(page).to have_content('Projetos') end end describe 'Add and delete a project' do visit '/projects/new' expect(page).to have_content('Novo') end end </code></pre> <p><strong>I'm looking for suggestions and pointers as to what might be my issue.</strong></p> <p><strong>P.S.:</strong> I'm running <code>rails (4.0.1)</code>, <code>capybara (2.2.0)</code>, <code>rspec-core (2.14.7)</code> <code>rspec-rails (2.14.0)</code></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload