Mano ah
2008-Oct-10 06:56 UTC
[rspec-users] rspec - undefined method `describe'' for main:Object
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 -- Posted via http://www.ruby-forum.com/.
Scott Taylor
2008-Oct-10 13:46 UTC
[rspec-users] rspec - undefined method `describe'' for main:Object
On Oct 10, 2008, at 2:56 AM, Mano ah 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''What''s in this file?> > #require ''./../../vendor/generators/rspec/lib/rspec_on_rails''You wont'' need this.> > #require ''sandbox_controller.rb''You won''t need this one, either> > require ''spec''Nor this> > gem ''rspec''Nor this.> > > describe SandboxController,"handling someaction" do > > it "should get real value 10" do > > get :someaction > > assigns[:value].should equal(10) > > end > > end > > > > My controller is >Why do you have a controller already? Scott
Mano ah
2008-Oct-11 03:16 UTC
[rspec-users] rspec - undefined method `describe'' for main:Object
Dear Scott, I am new to rspec and i am confused to test using it. Can you please help me with an easy example or link to get clear about it Regards M -- Posted via http://www.ruby-forum.com/.
Mano ah
2008-Oct-11 03:50 UTC
[rspec-users] rspec - undefined method `describe'' for main:Object
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: Finished in 0.437 seconds -- Posted via http://www.ruby-forum.com/.
Scott Taylor
2008-Oct-11 04:01 UTC
[rspec-users] rspec - undefined method `describe'' for main:Object
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:Looks like you''re writing controller specs. Have you checked out the rspec site? Specifically: http://rspec.info/documentation/rails/writing/controllers.html Scott
Scott Taylor
2008-Oct-11 04:08 UTC
[rspec-users] rspec - undefined method `describe'' for main:Object
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 #{RAILS_ROOT}/spec/controller/my_controller_spec.rb 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 ... end 4. Worse comes to worse, try running the generator to get some example code: ./script/generate rspec_controller MyController That should generate a sample spec. You could work from there. Hope that helps, Scott
Mano ah
2008-Oct-11 04:42 UTC
[rspec-users] rspec - undefined method `describe'' for main:Object
rails 2.1.1 and rspec 1.1.8 never worked out for me So i downgraded rails to 1.2.3. while execiting ruby /script/generate rspec_controller MyController it ask rails version 2.1.1. i was getting the describe method error as mention earlier in using 2.1.1 -- Posted via http://www.ruby-forum.com/.
Scott Taylor
2008-Oct-11 04:53 UTC
[rspec-users] rspec - undefined method `describe'' for main:Object
On Oct 11, 2008, at 12:42 AM, Mano ah wrote:> rails 2.1.1 and rspec 1.1.8 never worked out for me > > So i downgraded rails to 1.2.3. > > while execiting ruby /script/generate rspec_controller MyController > > it ask rails version 2.1.1. > > > i was getting the describe method error as mention earlier in using > 2.1.1Why don''t you post your spec? It would be a lot easier to help if we could look at the same thing you were looking at. Scott
Mano ah
2008-Oct-11 05:12 UTC
[rspec-users] rspec - undefined method `describe'' for main:Object
Scott Taylor wrote:> On Oct 11, 2008, at 12:42 AM, Mano ah wrote: > >> 2.1.1 > Why don''t you post your spec? It would be a lot easier to help if we > could look at the same thing you were looking at. > > Scottsorry spec? -- Posted via http://www.ruby-forum.com/.
Luis Lavena
2008-Oct-11 05:25 UTC
[rspec-users] rspec - undefined method `describe'' for main:Object
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
Mano ah
2008-Oct-11 06:44 UTC
[rspec-users] rspec - undefined method `describe'' for main:Object
Luis Lavena wrote:> On Fri, Oct 10, 2008 at 3:56 AM, Mano ah <lists at ruby-forum.com> wrote: >> c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:28:in `ge >> >> describe SandboxController,"handling someaction" do >> >> @value = somemethod >> >> 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.Thank you for the reply. I done the same and got the below error ** Invoke spec (first_time) ** Execute spec ** Invoke spec:models (first_time) ** Invoke db:test:prepare (first_time) ** Invoke environment (first_time) ** Execute environment ** Execute db:test:prepare ** Invoke db:test:clone (first_time) ** Invoke db:schema:dump (first_time) ** Invoke environment ** Execute db:schema:dump ** Invoke spec:controllers (first_time) ** Invoke db:test:prepare ** Execute spec:controllers rake aborted! RSpec failures D:/Diwakar/my_spec/config/../lib/tasks/rspec.rake:13 c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:617:in `call'' c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:617:in `execute'' c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:612:in `each'' c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:612:in `execute'' c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:578:in `invoke_with_call_c hain'' c:/ruby/lib/ruby/1.8/monitor.rb:242:in `synchronize'' c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:571:in `invoke_with_call_c hain'' c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:564:in `invoke'' c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:2019:in `invoke_task'' c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1997:in `top_level'' c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1997:in `each'' c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1997:in `top_level'' c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:2036:in `standard_exceptio n_handling'' c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1991:in `top_level'' c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1970:in `run'' c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:2036:in `standard_exceptio n_handling'' c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1967:in `run'' c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/bin/rake:31 c:/ruby/bin/rake:19:in `load'' c:/ruby/bin/rake:19> > 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-- Posted via http://www.ruby-forum.com/.
Mano ah
2008-Oct-11 06:53 UTC
[rspec-users] rspec - undefined method `describe'' for main:Object
my gem list is actionmailer (2.1.1, 1.3.3) actionpack (2.1.1, 1.13.3) actionwebservice (1.2.3) activerecord (2.1.1, 1.15.3) activeresource (2.1.1) activesupport (2.1.1, 1.4.2) fxri (0.3.6) fxruby (1.6.12) hoe (1.7.0) hpricot (0.6) log4r (1.0.5) rails (1.2.3) rake (0.8.3) rspec (1.1.8, 0.5.15) rspec-rails (1.1.8) rspec_generator (0.5.15) rubyforge (1.0.0) sources (0.0.1) win32-api (1.0.4) win32-clipboard (0.4.3) win32-dir (0.3.2) win32-eventlog (0.4.6) win32-file (0.5.4) win32-file-stat (1.2.7) win32-process (0.5.3) win32-sapi (0.1.4) win32-sound (0.4.1) win32console (1.1.0) windows-api (0.2.0) windows-pr (0.7.2) ZenTest (3.10.0) D:\Diwakar\my_spec> -- Posted via http://www.ruby-forum.com/.
Pat Maddox
2008-Oct-11 10:44 UTC
[rspec-users] rspec - undefined method `describe'' for main:Object
Dude, post your code On 10/10/08, Mano ah <lists at ruby-forum.com> wrote:> my gem list is > > > > actionmailer (2.1.1, 1.3.3) > actionpack (2.1.1, 1.13.3) > actionwebservice (1.2.3) > activerecord (2.1.1, 1.15.3) > activeresource (2.1.1) > activesupport (2.1.1, 1.4.2) > fxri (0.3.6) > fxruby (1.6.12) > hoe (1.7.0) > hpricot (0.6) > log4r (1.0.5) > rails (1.2.3) > rake (0.8.3) > rspec (1.1.8, 0.5.15) > rspec-rails (1.1.8) > rspec_generator (0.5.15) > rubyforge (1.0.0) > sources (0.0.1) > win32-api (1.0.4) > win32-clipboard (0.4.3) > win32-dir (0.3.2) > win32-eventlog (0.4.6) > win32-file (0.5.4) > win32-file-stat (1.2.7) > win32-process (0.5.3) > win32-sapi (0.1.4) > win32-sound (0.4.1) > win32console (1.1.0) > windows-api (0.2.0) > windows-pr (0.7.2) > ZenTest (3.10.0) > > D:\Diwakar\my_spec> > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
Mano ah
2008-Oct-11 10:59 UTC
[rspec-users] rspec - undefined method `describe'' for main:Object
I followed the below ways of installation 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 When i used ''rake spec'' i received no error. After that I created a controller then installed the two plugins ruby script/plugin install http://rspec.rubyforge.org/svn/tags/CURRENT/rspec ruby script/plugin install http://rspec.rubyforge.org/svn/tags/CURRENT/rspec_on_rails Then i used ''ruby script/generate rspec_scaffold myspec_con'' which created the spec for the controller,model etc Then i used the below command to run the spec file and received the below error D:\Diwakar\my_spec\spec>ruby script/spec controllers/myspec_cons_controller_spec .rb ruby: No such file or directory -- script/spec (LoadError) Please give your suggestions -- Posted via http://www.ruby-forum.com/.
Luis Lavena
2008-Oct-11 15:16 UTC
[rspec-users] rspec - undefined method `describe'' for main:Object
On Sat, Oct 11, 2008 at 7:59 AM, Mano ah <lists at ruby-forum.com> wrote:> > I followed the below ways of installation > > > 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 > > > When i used > > ''rake spec'' > > i received no error. > > After that I created a controller > > then installed the two plugins > > ruby script/plugin install > http://rspec.rubyforge.org/svn/tags/CURRENT/rspec > ruby script/plugin install > http://rspec.rubyforge.org/svn/tags/CURRENT/rspec_on_rails >You''re pulling a old SVN repository, latest releases are distributed through Git repo, please see the install instructions in the website: http://rspec.info> Then i used ''ruby script/generate rspec_scaffold myspec_con'' which > created the spec for the controller,model etc > > Then i used the below command to run the spec file and received the > below error > > D:\Diwakar\my_spec\spec>ruby script/spec > controllers/myspec_cons_controller_spec > .rb > ruby: No such file or directory -- script/spec (LoadError) > > Please give your suggestions >You forgot to: ruby script/generate rspec This is required for rspec to work, it generates the needed files in script and also spec folder to make RSpec work. Please do that and then try executing ruby script/spec. FYI: There are plenty of tutorials around the web that explain how to get started with RSpec. I guess english is not your main language and can be difficult to search for it, but: google with keywords "rspec rails getting started": http://www.jbrains.ca/permalink/127 http://github.com/dchelimsky/rspec-rails/wikis 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
David Chelimsky
2008-Oct-11 15:42 UTC
[rspec-users] rspec - undefined method `describe'' for main:Object
On Sat, Oct 11, 2008 at 10:16 AM, Luis Lavena <luislavena at gmail.com> wrote:> On Sat, Oct 11, 2008 at 7:59 AM, Mano ah <lists at ruby-forum.com> wrote: >> >> I followed the below ways of installation >> >> >> 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 >> >> >> When i used >> >> ''rake spec'' >> >> i received no error. >> >> After that I created a controller >> >> then installed the two plugins >> >> ruby script/plugin install >> http://rspec.rubyforge.org/svn/tags/CURRENT/rspec >> ruby script/plugin install >> http://rspec.rubyforge.org/svn/tags/CURRENT/rspec_on_rails >> > > You''re pulling a old SVN repository, latest releases are distributed > through Git repo, please see the install instructions in the website:I just blew away the contents of CURRENT, leaving a README that points to relevant information: http://rspec.rubyforge.org/svn/tags/CURRENT/README So this confusion over CURRENT should no longer be a problem :)> > http://rspec.info > >> Then i used ''ruby script/generate rspec_scaffold myspec_con'' which >> created the spec for the controller,model etc >> >> Then i used the below command to run the spec file and received the >> below error >> >> D:\Diwakar\my_spec\spec>ruby script/spec >> controllers/myspec_cons_controller_spec >> .rb >> ruby: No such file or directory -- script/spec (LoadError) >> >> Please give your suggestions >> > > You forgot to: > > ruby script/generate rspec > > This is required for rspec to work, it generates the needed files in > script and also spec folder to make RSpec work. > > Please do that and then try executing ruby script/spec. > > FYI: There are plenty of tutorials around the web that explain how to > get started with RSpec. I guess english is not your main language and > can be difficult to search for it, but: > > google with keywords "rspec rails getting started": > > http://www.jbrains.ca/permalink/127 > http://github.com/dchelimsky/rspec-rails/wikis > > 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 > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
Mano ah
2008-Oct-14 06:32 UTC
[rspec-users] rspec - undefined method `describe'' for main:Object
Thank you Pat Maddox,Douglas Adams,Luis Lavena,Scott Taylor for your kind help. I have installed the plugins rspec and rspec-rails using git. I was not running the spec controller from the root thats the main problem. I followed all of your useful suggestions and able to build and run a project sucessfully. Thank you once again. -- Posted via http://www.ruby-forum.com/.