Forum: Ruby Rspec loads routes twice

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:

`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:

Here's my routes.rb file:

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

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

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"

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'

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
, 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
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.