Fix spork error by using spork-rails gem

When setting up spork for use with rspec, I got an error: “unintialized constant ActiveModel::Observing (NameError)”.

Lesson learned: always check the latest documentation on GitHub before using a gem, in case things have changed since Ryan Bates made the Railscast!

There are two things I did differently from the Railscast in order to get things working:

  • Used the spork-rails gem rather than the spork gem
  • In the terminal, run “spork rspec –bootstrap” rather than “spork –bootstrap”

The old error:

Using RSpec
Preloading Rails environment
uninitialized constant ActiveModel::Observing (NameError)
/home/teddy/.rvm/gems/ruby-2.0.0-p247@intouchsys/gems/spork-0.9.2/lib/spork/app_framework/rails.rb:56:in `preload_rails’
/home/teddy/.rvm/gems/ruby-2.0.0-p247@intouchsys/gems/spork-0.9.2/lib/spork/app_framework/rails.rb:7:in `preload’
/home/teddy/.rvm/gems/ruby-2.0.0-p247@intouchsys/gems/spork-0.9.2/lib/spork/test_framework.rb:134:in `block in preload’
/home/teddy/.rvm/gems/ruby-2.0.0-p247@intouchsys/gems/spork-0.9.2/lib/spork.rb:62:in `exec_prefork’
/home/teddy/.rvm/gems/ruby-2.0.0-p247@intouchsys/gems/spork-0.9.2/lib/spork/test_framework.rb:120:in `preload’
/home/teddy/.rvm/gems/ruby-2.0.0-p247@intouchsys/gems/spork-0.9.2/lib/spork/run_strategy/forking.rb:25:in `preload’
/home/teddy/.rvm/gems/ruby-2.0.0-p247@intouchsys/gems/spork-0.9.2/lib/spork/runner.rb:74:in `run’
/home/teddy/.rvm/gems/ruby-2.0.0-p247@intouchsys/gems/spork-0.9.2/lib/spork/runner.rb:10:in `run’
/home/teddy/.rvm/gems/ruby-2.0.0-p247@intouchsys/gems/spork-0.9.2/bin/spork:10:in `<top (required)>’
/home/teddy/.rvm/gems/ruby-2.0.0-p247@intouchsys/bin/spork:23:in `load’
/home/teddy/.rvm/gems/ruby-2.0.0-p247@intouchsys/bin/spork:23:in `<main>’
/home/teddy/.rvm/gems/ruby-2.0.0-p247@intouchsys/bin/ruby_noexec_wrapper:14:in `eval’
/home/teddy/.rvm/gems/ruby-2.0.0-p247@intouchsys/bin/ruby_noexec_wrapper:14:in `<main>’

One Comment

  1. Hey, thanks for the post, I had the same error and got it fixed. However , you have to use the ‘spork (~> 1.0rc)’ also because spork-rails depending on ‘spork’

    here is my final version

    gem ‘spork’, ‘~> 1.0rc’
    gem ‘spork-rails’


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s