D
D
Dmitry2016-04-14 22:57:39
Ruby on Rails
Dmitry, 2016-04-14 22:57:39

Why does rspec duplicate the calls to routes.rb?

The rest of the application works fine, but the problem appeared with the advent of Capybara. But now removing the capybara does not help. The error remains(
Now, when rspec is called, there is an explicit double attempt to execute routes.rb:

$ bundle exec rspec
--- here ---
--- here ---
/Users/svetozar/.rvm/gems/[email protected]_rails_4_0/gems/actionpack-4.2.4/lib/action_dispatch/routing/route_set.rb:557: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..org/routing.html#restricting-the-routes-created
  from /Users/svetozar/.rvm/gems/[email protected]_rails_4_0/gems/actionpack-4.2.4/lib/action_dispatch/routing/mapper.rb:1561:in `add_route'
  from /Users/svetozar/.rvm/gems/[email protected]_rails_4_0/gems/actionpack-4.2.4/lib/action_dispatch/routing/mapper.rb:1536:in `decomposed_match'
  from /Users/svetozar/.rvm/gems/[email protected]_rails_4_0/gems/actionpack-4.2.4/lib/action_dispatch/routing/mapper.rb:1517:in `block in match'
  from /Users/svetozar/.rvm/gems/[email protected]_rails_4_0/gems/actionpack-4.2.4/lib/action_dispatch/routing/mapper.rb:1507:in `each'
  from /Users/svetozar/.rvm/gems/[email protected]_rails_4_0/gems/actionpack-4.2.4/lib/action_dispatch/routing/mapper.rb:1507:in `match'
и т.д. ...

"--- here ---" I specifically type this in routes.rb myself to track the double call:
require 'sidekiq/web'
Rails.application.routes.draw do
  puts "--- here ---"
  ### ГЛАВНОЕ
  root 'service#home'
  # ...

The route can be generally one root, but it will still be called twice and the console clears its throat ... Attempts to find an answer on the Internet have not led to anything, although the problem is common.
The launch rails s -e testdoes not generate any errors. Also, calling the same versions of Capybara and Rspec on a nearby test project doesn't throw any errors...
My Gemfile:
source 'http://rubygems.org'

gem 'rails', '4.2.4'
gem 'sass-rails', '~> 4.0.3'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.0.0'

gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0',          group: :doc

gem 'bcrypt-ruby', '~> 3.1', '>= 3.1.5'

gem 'tzinfo-data', platforms: [:mingw, :mswin]

gem 'haml'
gem 'bootstrap-sass'

gem 'devise'
gem 'cancancan'
gem 'rolify'

gem 'russian'
gem 'ancestry'
gem 'paperclip' #, : 'thoughtbot/paperclip'
gem 'activerecord-session_store' #, : 'rails/activerecord-session_store'

gem 'will_paginate', '~> 3.1'

# поиск
gem 'sunspot_rails'
gem 'date_diff'

# фоновые задачи
gem 'redis-namespace'
gem 'sidekiq', '~> 4.1'
gem 'sidekiq-status'
gem 'sidekiq_mailer'
gem 'sinatra', require: false

group :production do
  gem 'mysql2', '~> 0.3.20'
  gem 'therubyracer', platform: :ruby 
  gem 'execjs'
end

group :development do
  gem 'capistrano-rails'
  gem 'capistrano-rvm'
  gem 'capistrano-passenger'
  gem 'capistrano-bundler'
  gem 'capistrano-sidekiq'
  gem 'progress_bar'
  gem 'better_errors'
  gem 'binding_of_caller'
end

group :development, :test do
  gem 'sunspot_solr'
  gem 'puma'
end

group :test do
  gem 'rspec-rails', '~> 3.4', '>= 3.4.2'
  gem 'factory_girl_rails', '~> 4.5'
  gem 'capybara', '~> 2.5'
end

Gem versions:
capybara (2.7.0)
factory_girl (4.7.0)
factory_girl_rails (4.7.0)
rspec-core (3.4.4)
rspec-expectations (3.4.0)
rspec-mocks (3.4.1)
rspec-rails (3.4 ) .2)
rspec-support (3.4.1)
update:
I tried to install vagrant-virtual to try to install gems from scratch - everything works without problems ...
update2:
I tried it on virtual linux - just rspec works, but bundle exec rspec gives the same error again...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Y
Yuri Izotov, 2016-04-16
@railsfun

Check if it is written somewhere that
it reloads routes while the application is running. Although even so, if you don't have duplicates in your routes, you shouldn't swear...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question