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

Luis Lavena luislavena at gmail.com
Sat Oct 11 01:25:34 EDT 2008


On Fri, Oct 10, 2008 at 3:56 AM, Mano ah <lists at ruby-forum.com> wrote:
>
>
> When i run a spec file i am getting the following error
>
>  D:\Diwakar\spec_diwa\spec\controllers>spec sandbox_controller_spec.rb
> c:/ruby/lib/ruby/gems/1.8/gems/rspec-0.5.15/lib/spec/api/sugar.rb:17:in
> `method_
> missing': undefined method `describe' for main:Object (NoMethodError)
>        from ./sandbox_controller_spec.rb:7
>        from
> c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:28:in `ge
> m_original_require'
>        from
> c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:28:in `re
> quire'
>        from c:/ruby/lib/ruby/gems/1.8/gems/rspec-0.5.15/bin/spec:13
>        from c:/ruby/lib/ruby/gems/1.8/gems/rspec-0.5.15/bin/spec:7:in
> `each'
>        from c:/ruby/lib/ruby/gems/1.8/gems/rspec-0.5.15/bin/spec:7
>        from c:/ruby/bin/spec:19:in `load'
>        from c:/ruby/bin/spec:19
>
>
>
> My spec controller is
>
> require File.dirname(__FILE__) + '/../spec_helper'
> #require './../../vendor/generators/rspec/lib/rspec_on_rails'
> #require 'sandbox_controller.rb'
> require 'spec'
> gem 'rspec'
>
> describe SandboxController,"handling someaction" do
>
>  it "should get real value 10" do
>
>    get :someaction
>
>    assigns[:value].should equal(10)
>
>  end
>
> end
>
>
>
> My controller is
>
>
>
> class SandboxController < ApplicationController
>
>  def someaction
>
>    @value = somemethod
>
>  end
>
>
>  protected
>
>
>  def somemethod
>
>    return 10
>
>  end
>
> end
>
> Please help me to solve the issue
>

Sorry, jumping late on this issue.

It appears you're calling 'spec' from the command line, which is
loading your installed gem of RSpec.

Based on the output of the backtrace, it appears to be version 0.5.15

You should have used "ruby script/spec" from the root of your rails
application instead.

Also, if you changed versions of Rails, you need to update
config/environment.rb to match the Rails gem version since you
downgraded to 1.2.3 but forgot to change that file.

I suggest you do this:

gem install rake
gem install rails
gem install rspec
gem install rspec-rails

rails my-test-app
cd my-test-app
ruby script/generate rspec
rake spec

That, at least, should work and not generate empty errors (well, I've
skipped database setup, controller and such, please add those after).

HTH,
-- 
Luis Lavena
AREA 17
-
Human beings, who are almost unique in having the ability to learn from
the experience of others, are also remarkable for their apparent
disinclination to do so.
Douglas Adams


More information about the rspec-users mailing list