[rspec-users] rspec - undefined method `describe' for main:Object

Scott Taylor mailing_lists at railsnewbie.com
Sat Oct 11 00:08:47 EDT 2008

On Oct 10, 2008, at 11:50 PM, Mano ah wrote:

> How to solve the below error
> 1)
> NoMethodError in 'LoginController index should get successfully'
> You have a nil object when you didn't expect it!
> The error occurred while evaluating nil.status
> ./login_controller_spec.rb:9:
> 2)
> NoMethodError in 'LoginController index should render 202 file'
> undefined method `render_template' for
> #<Spec::Example::ExampleGroup::Subclass_1
> :0x47bc128>
> ./login_controller_spec.rb:13:

"Spec::Example::ExampleGroup::Subclass_1" - this part suggests it's  
not running as a controller spec.  A few things:

1. Is the file in correct path?  It should be in the path  

2. Have you installed the two plugins, and run "script/generate rspec" ?

3.  (I don't recommend this, but:) You can force this to run as a  
controller spec by passing a :type => :controller to describe, like so:

describe "my controller", :type => :controller do

4. Worse comes to worse, try running the generator to get some example  

./script/generate rspec_controller MyController

That should generate a sample spec.  You could work from there.

Hope that helps,


More information about the rspec-users mailing list