Rspec error: `inherited': You cannot have more than one Rails::Application (RuntimeError)

Some background:

I set up my first rails app for testing with rspec, and everything
worked fine: I could run tests, etc. Then I created a second rails app
to play around with (and a third, fourth). But I can’t get testing to
work with my second rails app. When I cd’ed to my second app’s
directory and did this:

$ bundle exec rspec spec/

it ran the tests for my first app. My first app has about 150 tests,
and my second app has 3 tests, so it was obviously not running the
correct tests. In an attempt to cure that problem, I took these
steps:

  1. I closed out all windows on my computer.
  2. I restarted my computer.
  3. I opened a terminal window and cd’ed into my second apps directory,
    and then I did this:

$ bundle exec rpsec spec/

and I got this error:

No DRb server is running. Running in local process instead …
/Users/me/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/railties-3.0.9/lib/rails/application.rb:63:in
inherited': You cannot have more than one Rails::Application (RuntimeError) from /Users/me/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/railties-3.0.9/lib/rails/deprecation.rb:7:ininitialize’
from
/Users/me/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/railties-3.0.9/lib/rails/deprecation.rb:7:in
new' from /Users/me/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/railties-3.0.9/lib/rails/deprecation.rb:7:inrun’
from
/Users/me/rails_projects/test_app/app/models/generate/config/environment.rb:9:in
<top (required)>' from /Users/me/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:454:inload’
from
/Users/me/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:454:in
block in load_file' from /Users/me/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:596:innew_constants_in’
from
/Users/me/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:453:in
load_file' from /Users/me/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:340:inrequire_or_load’
from
/Users/me/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:300:in
depend_on' from /Users/me/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:216:inrequire_dependency’
from
/Users/me/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/railties-3.0.9/lib/rails/engine.rb:138:in
block (2 levels) in eager_load!' from /Users/me/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/railties-3.0.9/lib/rails/engine.rb:137:ineach’
from
/Users/me/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/railties-3.0.9/lib/rails/engine.rb:137:in
block in eager_load!' from /Users/me/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/railties-3.0.9/lib/rails/engine.rb:135:ineach’
from
/Users/me/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/railties-3.0.9/lib/rails/engine.rb:135:in
eager_load!' from /Users/me/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/railties-3.0.9/lib/rails/application.rb:108:ineager_load!’
from
/Users/me/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/railties-3.0.9/lib/rails/application/finisher.rb:41:in
block in <module:Finisher>' from /Users/me/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/railties-3.0.9/lib/rails/initializable.rb:25:ininstance_exec’
from
/Users/me/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/railties-3.0.9/lib/rails/initializable.rb:25:in
run' from /Users/me/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/railties-3.0.9/lib/rails/initializable.rb:50:inblock in run_initializers’
from
/Users/me/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/railties-3.0.9/lib/rails/initializable.rb:49:in
each' from /Users/me/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/railties-3.0.9/lib/rails/initializable.rb:49:inrun_initializers’
from
/Users/me/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/railties-3.0.9/lib/rails/application.rb:134:in
initialize!' from /Users/me/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/railties-3.0.9/lib/rails/application.rb:77:inmethod_missing’
from /Users/me/rails_projects/test_app/config/environment.rb:5:in
<top (required)>' from /Users/me/rails_projects/test_app/spec/spec_helper.rb:14:inrequire’
from /Users/me/rails_projects/test_app/spec/spec_helper.rb:14:in
block in <top (required)>' from /Users/me/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/spork-0.9.0.rc8/lib/spork.rb:24:inprefork’
from /Users/me/rails_projects/test_app/spec/spec_helper.rb:4:in <top (required)>' from /Users/me/rails_projects/test_app/spec/controllers/pages_controller_spec.rb:1:inrequire’
from
/Users/me/rails_projects/test_app/spec/controllers/pages_controller_spec.rb:1:in
<top (required)>' from /Users/me/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/rspec-core-2.6.4/lib/rspec/core/configuration.rb:419:inload’
from
/Users/me/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/rspec-core-2.6.4/lib/rspec/core/configuration.rb:419:in
block in load_spec_files' from /Users/me/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/rspec-core-2.6.4/lib/rspec/core/configuration.rb:419:inmap’
from
/Users/me/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/rspec-core-2.6.4/lib/rspec/core/configuration.rb:419:in
load_spec_files' from /Users/me/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/rspec-core-2.6.4/lib/rspec/core/command_line.rb:18:inrun’
from
/Users/me/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/rspec-core-2.6.4/lib/rspec/core/runner.rb:80:in
run_in_process' from /Users/me/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/rspec-core-2.6.4/lib/rspec/core/runner.rb:66:inrescue in run’
from
/Users/me/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/rspec-core-2.6.4/lib/rspec/core/runner.rb:62:in
run' from /Users/me/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/rspec-core-2.6.4/lib/rspec/core/runner.rb:11:inblock in autorun’

====

My Gemfiles are exactly the same for each app. If I cd into my first
app’s directory, and then do this:

$ bundle exec rspec spec/

it runs all my first apps tests.

cross posted here:

Jim ruther Nill wrote in post #1019886:

On Sat, Sep 3, 2011 at 7:55 AM, 7stud – [email protected] wrote:

cross posted here:

ruby on rails - rspec runs the tests in another app - Stack Overflow

Haven’t encountered that error before. But googling the error message
gives
quite a few useful results (i think) :smiley:

Nope. Google returns no information about the error.

I have come to the conclusion that my problem has to do with the name of
my app–it’s test_app. I created another app and after running through
the extensive setup, I can now run rspec tests on it. For my test_app,
I tried deleting the gemset and reinstalling rails and all the gems, but
I could never get the tests to work.

On Sat, Sep 3, 2011 at 7:55 AM, 7stud – [email protected] wrote:

cross posted here:

ruby on rails - rspec runs the tests in another app - Stack Overflow

Haven’t encountered that error before. But googling the error message
gives
quite a few useful results (i think) :smiley:

http://groups.google.com/group/rubyonrails-talk?hl=en.