Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
daveheitzman opened this issue Feb 9, 2012 · 2 comments
Closed

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

daveheitzman opened this issue Feb 9, 2012 · 2 comments

Comments

@daveheitzman
Copy link

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

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
end
end

@dchelimsky
Copy link
Contributor

Why did you close this?

@daveheitzman
Copy link
Author

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 reply@reply.github.com
To: David Heitzman daveheitzman@yahoo.com
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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants