[rspec-users] Cryptic error message when no controller_name

Francois Beausoleil francois.beausoleil at gmail.com
Sun Jan 28 22:12:30 EST 2007


Hi !

In the following spec:

context "A project owner" do
  specify "can assign roles to other users" do
    # ...
  end
end

I get the following cryptic error message:

1)
NoMethodError in 'A project owner can assign roles to other users'
undefined method `session=' for #<Object:0xb741bed4>
/home/francois/src/smrty2/vendor/plugins/rspec_on_rails/lib/spec/rails/context/controller.rb:134:in
`setup_extra'
/home/francois/src/smrty2/vendor/plugins/rspec_on_rails/lib/spec/rails/functional_eval_context.rb:22:in
`setup'
/home/francois/src/smrty2/vendor/plugins/rspec_on_rails/lib/spec/rails/context/controller.rb:151:in
`setup'

Line 134 of controller.rb is:

@controller.session = session

We are probably only missing a check to ensure that @controller is
somehow defined.  Failing that should simply say "You forgot to define
controller_name in your controller spec".

This is on 0.7.5.1.

Thanks !
-- 
François Beausoleil
http://blog.teksol.info/
http://piston.rubyforge.org/


More information about the rspec-users mailing list