RSpec.configure not including capybara dsl in spec_helper.rb #503

daveheitzman opened this Issue Feb 9, 2012 · 2 comments


None yet

2 participants

rspec-rails: 2.8.1
capybara: 1.1.2

in new rails 3.2 app (using either MRI 1.9.2 or 1.9.3) tests are failing with the error:
undefined method `visit' for #RSpec::Core::ExampleGroup::Nested_1:0x00000003e05580

(visit is a capybara method that loads a page, like webrat's get)

capybara gets this method included in the rspec framework by this line in spec_helper:
require 'capybara/rspec'
this in turn runs a block like :

RSpec.configure do |config|

this is not working to include the Capybara dsl methods.

An ugly workaround fixes the problem:
insert the following lines into spec_helper.rb

module ::RSpec::Core
class ExampleGroup
include Capybara::DSL
include Capybara::RSpecMatchers


Why did you close this?

It is because the problem lies with my directory naming. tl;dr you need to name the integration test directory 'requests' (plural). I had been naming it request.

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

the :request symbol causes rspec to only include if the directory is named requests

it would be cool if it accepted both, but really that doesn' matter. if a person is ignorant of this arrangement they will still not be able to get capy working. There needs to be a neon sign for users to tell them that the name of the directory is critical. I don't know whether that's rspec's responsibility or capybara's, or google's.

thanks for all your work on rspec. it's good software.

David Heitzman

From: David Chelimsky
To: David Heitzman
Sent: Thursday, February 9, 2012 1:07 PM
Subject: Re: [rspec-rails] RSpec.configure not including capybara dsl in spec_helper.rb (#503)

Why did you close this?

Reply to this email directly or view it on GitHub:
#503 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment