Forum: Ruby Rspec loads routes twice

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
76dd12d44b6807687c20dc7c013cfa4e?d=identicon&s=25 Abraham Lincoln (chemista)
on 2014-03-27 19:56
I've been trying to figure this out for a couple of days with no luck.
Searching the Internet doesn't lead to much. When I run rspec it's
giving the following error:

/home/user/.rvm/gems/ruby-2.0.0-p247/gems/actionpack-4.0.1/lib/action_dispatch/routing/route_set.rb:434:in
`add_route': Invalid route name, already in use: 'root'  (ArgumentError)
You may have defined two routes with the same name using the `:as`
option, or you may be overriding a route already defined by a resource
with the same naming. For the latter, you can restrict the routes
created with `resources` as explained here:
http://guides.rubyonrails.org/routing.html#restric...

Here's my routes.rb file:

App::Application.routes.draw do
  root 'registrations#new'
end

There are other things in it, but I can comment them all out and still
get the error. Therefore they are not relevant.

spec_helper.rb :

ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'rspec/autorun'
#Capybara
require 'capybara/rspec'

Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }

# Checks for pending migrations before tests are run.
# If you are not using ActiveRecord, you can remove this line.
ActiveRecord::Migration.check_pending! if
defined?(ActiveRecord::Migration)

RSpec.configure do |config|
  config.include Helpers

  config.fixture_path = "#{::Rails.root}/spec/fixtures"
  config.use_transactional_fixtures = true
  config.infer_base_class_for_anonymous_controllers = false
  config.order = "random"
end

Part of my Gemfile

group :development, :test do
  gem 'launchy'
  gem 'rspec-rails', '~> 2.0'
  gem 'capybara', '~> 2.1.0'
  gem 'factory_girl_rails', '~> 4.0'
end

The problem is that Rspec is trying to load routes.rb twice. I tested
this by putting puts "here" in routes.rb file. For the love of Ruby I
cannot figure out why, or how to possibly debug this. When I run rake
routes it only shows one route for root and if I comment it out in
routes.rb, then it does not show. It seems like everything is correct
basically, except that rspec is not working. Also, here's a similar
problem
http://stackoverflow.com/questions/22473157/when-i...
, unfortunately I don't even know if it's the same problem or not, and
it's not helping me find a solution. Please help, I'm really stuck on
this one. Any suggestions would be good right now.
I posted this on SO as well, but they might delete it for one of their
bad reasons. So hopefully someone here can help me. Also sorry if all
the spaces, paragraph brakes etc. are collapsed in the final post,
that's not my fault. ^_^ thanks
This topic is locked and can not be replied to.