Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails 4.0 Spork/ActiveRecord exception

Tags:

I've been using Michael Hartl's Rails Tutorial to pick up Ruby on Rails and have recently been going through the new Rails 4.0 version of the tutorial. I've encountered an issue with Spork; I know that we're using a custom fork of Spork for Rails 4.0 compatibility, and that this may just be a different incompatibility, but I wanted to post my issue and see if I was just doing something wrong or if anyone had any ideas. Whenever I call RSpec while Spork is running I get an ActiveRecord exception, while if I call RSpec by itself my tests run successfully - an example terminal dump is below:

oren@VM:~/ruby_projects/test_app$ rspec Exception encountered: #<ActiveRecord::ConnectionNotEstablished: ActiveRecord::ConnectionNotEstablished> backtrace: /home/oren/.rvm/gems/ruby-2.0.0-p195@rails_4_0/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:546:in `retrieve_connection' /home/oren/.rvm/gems/ruby-2.0.0-p195@rails_4_0/gems/activerecord-4.0.0/lib/active_record/connection_handling.rb:79:in `retrieve_connection' /home/oren/.rvm/gems/ruby-2.0.0-p195@rails_4_0/gems/activerecord-4.0.0/lib/active_record/connection_handling.rb:53:in `connection' /home/oren/.rvm/gems/ruby-2.0.0-p195@rails_4_0/gems/activerecord-4.0.0/lib/active_record/migration.rb:792:in `current_version' /home/oren/.rvm/gems/ruby-2.0.0-p195@rails_4_0/gems/activerecord-4.0.0/lib/active_record/migration.rb:800:in `needs_migration?' /home/oren/.rvm/gems/ruby-2.0.0-p195@rails_4_0/gems/activerecord-4.0.0/lib/active_record/migration.rb:379:in `check_pending!' /home/oren/ruby_projects/test_app/spec/spec_helper.rb:105:in `<top (required)>' /home/oren/.rvm/gems/ruby-2.0.0-p195@rails_4_0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:222:in `load' /home/oren/.rvm/gems/ruby-2.0.0-p195@rails_4_0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:222:in `block in load' /home/oren/.rvm/gems/ruby-2.0.0-p195@rails_4_0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:213:in `load_dependency' /home/oren/.rvm/gems/ruby-2.0.0-p195@rails_4_0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:222:in `load' /home/oren/.rvm/gems/ruby-2.0.0-p195@rails_4_0/gems/spork-1.0.0rc3/lib/spork/run_strategy/forking.rb:11:in `block in run' /home/oren/.rvm/gems/ruby-2.0.0-p195@rails_4_0/gems/spork-1.0.0rc3/lib/spork/forker.rb:21:in `block in initialize' /home/oren/.rvm/gems/ruby-2.0.0-p195@rails_4_0/gems/spork-1.0.0rc3/lib/spork/forker.rb:18:in `fork' /home/oren/.rvm/gems/ruby-2.0.0-p195@rails_4_0/gems/spork-1.0.0rc3/lib/spork/forker.rb:18:in `initialize' /home/oren/.rvm/gems/ruby-2.0.0-p195@rails_4_0/gems/spork-1.0.0rc3/lib/spork/run_strategy/forking.rb:9:in `new' /home/oren/.rvm/gems/ruby-2.0.0-p195@rails_4_0/gems/spork-1.0.0rc3/lib/spork/run_strategy/forking.rb:9:in `run' /home/oren/.rvm/gems/ruby-2.0.0-p195@rails_4_0/gems/spork-1.0.0rc3/lib/spork/server.rb:48:in `run' /home/oren/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/2.0.0/drb/drb.rb:1588:in `perform_without_block' /home/oren/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/2.0.0/drb/drb.rb:1548:in `perform' /home/oren/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/2.0.0/drb/drb.rb:1626:in `block (2 levels) in main_loop' /home/oren/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/2.0.0/drb/drb.rb:1622:in `loop' /home/oren/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/2.0.0/drb/drb.rb:1622:in `block in main_loop' 

I can provide any files from my app upon request, I'm just not sure what would be the most useful. I basically followed the first few steps of Chapter 3 of the tutorial (setting up new app, adding StaticPages controller, setting up RSpec, and adding the first spec) and the instructions for setting up Guard and Spork (Sec. 3.6.2 and 3.6.3).

Thanks for your help!

like image 489
orenyk Avatar asked Jun 26 '13 04:06

orenyk


1 Answers

Your spec/spec_helper.rb likely has issues. Replace what you have with https://github.com/railstutorial/sample_app_rails_4/blob/master/spec/spec_helper.rb and see if that gets rid of the issue.

like image 198
zgohr Avatar answered Sep 19 '22 05:09

zgohr