Why @controller is nil error on loading fixtures in model?

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

On Sat, Oct 18, 2008 at 6:10 PM, Harry B. [email protected]
wrote:

‘/…/helpers/votes_spec_helper’)

but no change.

I would appreciate some assistance here to get this off the ground.

It’s being you are calling “put” and I believe you want “puts”. The
method “put” is a Rails testing method which tries to invoke a PUT
http request on a given controller action. That is why you are getting
@controller is nil.


Zach D.
http://www.continuousthinking.com

Zach D. wrote:

On Sat, Oct 18, 2008 at 6:10 PM, Harry B. [email protected]
wrote:

‘/…/helpers/votes_spec_helper’)

but no change.

I would appreciate some assistance here to get this off the ground.

It’s being you are calling “put” and I believe you want “puts”. The
method “put” is a Rails testing method which tries to invoke a PUT
http request on a given controller action. That is why you are getting
@controller is nil.


Zach D.
http://www.continuousthinking.com
http://www.mutuallyhuman.com

yes that was the problem. That d*** dyslexia again.
Thanks very much, as frustration had set in.
HR