Folder structure when using spec-rails with Capybara

231 views
Skip to first unread message

Javix

unread,
Feb 28, 2013, 5:10:13 AM2/28/13
to rs...@googlegroups.com
It seems to be a little strange, as if it misses something in setup instructions for spec-rails and capybara.
I tried to use the following 2 versions (here is an extract from the RoR Gemfile):

group :development, :test do
  gem "rspec-rails", "~> 2.13.0"
end

group :test do
  gem 'capybara', '~> 2.0.2'
  gem 'database_cleaner', '~> 0.9.1'
  gem 'launchy', '~> 2.2.0'
end

As advised at Capybara site, I added the following 2 lines to spec_helper.rb file:
If you are using Rails, add this line to your test helper file:
require 'capybara/rails'

Load RSpec 2.x support by adding the following line (typically to your spec_helper.rb file):
require 'capybara/rspec'

Then, as it is said at Capybara:
If you are using Rails, put your Capybara specs in spec/features.

So if I put the specs as I had before in my spec/requests folder in spec/features it works.
But it fails to find Capybara 'visit' method if I leave the spec in spec/requests folder:

StaticPages
  Home page
    example at ./spec/requests/static_pages_spec.rb:10 (FAILED - 1)
    example at ./spec/requests/static_pages_spec.rb:11 (FAILED - 2)

Failures:

  1) StaticPages Home page 
     Failure/Error: before { visit '/static_pages/home' }
     NoMethodError:
       undefined method `visit' for #<RSpec::Core::ExampleGroup::Nested_1::Nested_1:0x007fb4ffc60d70>
     # ./spec/requests/static_pages_spec.rb:8:in `block (3 levels) in <top (required)>'

  2) StaticPages Home page 
     Failure/Error: before { visit '/static_pages/home' }
     NoMethodError:
       undefined method `visit' for #<RSpec::Core::ExampleGroup::Nested_1::Nested_1:0x007fb4ff85e100>
     # ./spec/requests/static_pages_spec.rb:8:in `block (3 levels) in <top (required)>'

Finished in 0.01803 seconds
2 examples, 2 failures


Any ideas? So no more possible to have the 'old' RSpec structure with separate controllers, requests... folders ?

Thanks you.

Javix

unread,
Feb 28, 2013, 6:19:15 AM2/28/13
to rs...@googlegroups.com
 The answer to the question is here and well explained:


Hope this helps
Reply all
Reply to author
Forward
0 new messages