[rspec-users] Why @controller is nil error on loading fixtures in model?

Harry Bishop lists at ruby-forum.com
Sat Oct 18 18:10:35 EDT 2008


Hi,
  I'm new to rspec and working on catching up my app with rspec testing.
I'm running OSX 10.5.5 with Rails 2.1.0 and Rspec 1.1.8.
Most things I've tried work except loading fixtures.  I setup a describe
block for the model as

require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
require File.expand_path(File.dirname(__FILE__) +
'/../helpers/motions_spec_helper')
require File.expand_path(File.dirname(__FILE__) +
'/../helpers/votes_spec_helper')

describe "description" do

    fixtures :motions

  it "reads from fixtures" do

    put "#{motions(:one).inspect}"
  end
end

I receive @controller is nil: make sure you set it in your test's setup
method.
as the error when running the example test in rspec.  I know it is
finding the fixture because it balked at duplicate id entries with
SQLite.  I fixed that and now receive the above message.

I tried various setting changes in spec_helper.rb but nothing seems to
work.
After searching around I tried various terminal entries like
rake spec:db:fixtures:load
but no change.

I would appreciate some assistance here to get this off the ground.
TIA,
HR
-- 
Posted via http://www.ruby-forum.com/.


More information about the rspec-users mailing list