daze
2010-Dec-15 03:43 UTC
Having trouble testing :( "superclass mismatch" and can''t load "test_helper"
I''m having trouble testing my Rails 3 application. Unit testing doesn''t work. If I try ruby article_test.rb directly, I get a "no such file to load" error, and if I try rake test:units or ruby unit/ article_test.rb I get this odd "superclass mismatch for class ArticlesController" error! I''m hoping I can get this settled... My test files were generated by the generator... C:\Users\Family\workspace\jdrampage\test\unit>ruby article_test.rb C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'': no such file to load -- test_helper (LoadError) from C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/ custom_require.rb:31:in `require'' from article_test.rb:1 C:\Users\Family\workspace\jdrampage\test\unit>cd.. C:\Users\Family\workspace\jdrampage\test>ruby unit/article_test.rb C:/Users/Family/workspace/jdrampage/app/controllers/ articles_controller.rb:1: superclass mismatch for class ArticlesController (TypeError) from C:/Ruby187/lib/ruby/gems/1.8/gems/activesupport-3.0.3/lib/ active_support/dependencies.rb:239:in `require'' from C:/Ruby187/lib/ruby/gems/1.8/gems/activesupport-3.0.3/lib/ active_support/dependencies.rb:239:in `require'' from C:/Ruby187/lib/ruby/gems/1.8/gems/activesupport-3.0.3/lib/ active_support/dependencies.rb:227:in `load_dependency'' from C:/Ruby187/lib/ruby/gems/1.8/gems/activesupport-3.0.3/lib/ active_support/dependencies.rb:239:in `require'' from C:/Ruby187/lib/ruby/gems/1.8/gems/activesupport-3.0.3/lib/ active_support/dependencies.rb:346:in `require_or_load'' from C:/Ruby187/lib/ruby/gems/1.8/gems/activesupport-3.0.3/lib/ active_support/dependencies.rb:300:in `depend_on'' from C:/Ruby187/lib/ruby/gems/1.8/gems/activesupport-3.0.3/lib/ active_support/dependencies.rb:216:in `require_dependency'' from C:/Ruby187/lib/ruby/gems/1.8/gems/railties-3.0.3/lib/ rails/engine.rb:138:in `eager_load!'' from C:/Ruby187/lib/ruby/gems/1.8/gems/railties-3.0.3/lib/ rails/engine.rb:137:in `each'' from C:/Ruby187/lib/ruby/gems/1.8/gems/railties-3.0.3/lib/ rails/engine.rb:137:in `eager_load!'' from C:/Ruby187/lib/ruby/gems/1.8/gems/railties-3.0.3/lib/ rails/engine.rb:135:in `each'' from C:/Ruby187/lib/ruby/gems/1.8/gems/railties-3.0.3/lib/ rails/engine.rb:135:in `eager_load!'' from C:/Ruby187/lib/ruby/gems/1.8/gems/railties-3.0.3/lib/ rails/application.rb:108:in `eager_load!'' from C:/Ruby187/lib/ruby/gems/1.8/gems/railties-3.0.3/lib/ rails/application/finisher.rb:41 from C:/Ruby187/lib/ruby/gems/1.8/gems/railties-3.0.3/lib/ rails/initializable.rb:25:in `instance_exec'' from C:/Ruby187/lib/ruby/gems/1.8/gems/railties-3.0.3/lib/ rails/initializable.rb:25:in `run'' from C:/Ruby187/lib/ruby/gems/1.8/gems/railties-3.0.3/lib/ rails/initializable.rb:50:in `run_initializers'' from C:/Ruby187/lib/ruby/gems/1.8/gems/railties-3.0.3/lib/ rails/initializable.rb:49:in `each'' from C:/Ruby187/lib/ruby/gems/1.8/gems/railties-3.0.3/lib/ rails/initializable.rb:49:in `run_initializers'' from C:/Ruby187/lib/ruby/gems/1.8/gems/railties-3.0.3/lib/ rails/application.rb:134:in `initialize!'' from C:/Ruby187/lib/ruby/gems/1.8/gems/railties-3.0.3/lib/ rails/application.rb:77:in `send'' from C:/Ruby187/lib/ruby/gems/1.8/gems/railties-3.0.3/lib/ rails/application.rb:77:in `method_missing'' from C:/Users/Family/workspace/jdrampage/config/environment.rb: 5 from C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/ custom_require.rb:31:in `gem_original_require'' from C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/ custom_require.rb:31:in `require'' from ./test_helper.rb:2 from C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/ custom_require.rb:31:in `gem_original_require'' from C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/ custom_require.rb:31:in `require'' from unit/article_test.rb:1 -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
David Kahn
2010-Dec-15 03:58 UTC
Re: Having trouble testing :( "superclass mismatch" and can''t load "test_helper"
On Tue, Dec 14, 2010 at 9:43 PM, daze <dmonopoly10-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I''m having trouble testing my Rails 3 application. Unit testing > doesn''t work. If I try ruby article_test.rb directly, I get a "no > such file to load" error, and if I try rake test:units or ruby unit/ > article_test.rb I get this odd "superclass mismatch for class > ArticlesController" error! > > I''m hoping I can get this settled... > My test files were generated by the generator... > > C:\Users\Family\workspace\jdrampage\test\unit>ruby article_test.rb > C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in > `gem_original_require'': no such file to load -- test_helper > (LoadError) > from C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/ > custom_require.rb:31:in `require'' > from article_test.rb:1 > > C:\Users\Family\workspace\jdrampage\test\unit>cd.. > > C:\Users\Family\workspace\jdrampage\test>ruby unit/article_test.rb > C:/Users/Family/workspace/jdrampage/app/controllers/ > articles_controller.rb:1: superclass mismatch for class > ArticlesController (TypeError) >Did you look at your ArticlesController for clues? Also, does your app function through the browser but not running the tests? Would not hurt to copy your ArticlesController here, and maybe also your Environment.rb> from C:/Ruby187/lib/ruby/gems/1.8/gems/activesupport-3.0.3/lib/ > active_support/dependencies.rb:239:in `require'' > from C:/Ruby187/lib/ruby/gems/1.8/gems/activesupport-3.0.3/lib/ > active_support/dependencies.rb:239:in `require'' > from C:/Ruby187/lib/ruby/gems/1.8/gems/activesupport-3.0.3/lib/ > active_support/dependencies.rb:227:in `load_dependency'' > from C:/Ruby187/lib/ruby/gems/1.8/gems/activesupport-3.0.3/lib/ > active_support/dependencies.rb:239:in `require'' > from C:/Ruby187/lib/ruby/gems/1.8/gems/activesupport-3.0.3/lib/ > active_support/dependencies.rb:346:in `require_or_load'' > from C:/Ruby187/lib/ruby/gems/1.8/gems/activesupport-3.0.3/lib/ > active_support/dependencies.rb:300:in `depend_on'' > from C:/Ruby187/lib/ruby/gems/1.8/gems/activesupport-3.0.3/lib/ > active_support/dependencies.rb:216:in `require_dependency'' > from C:/Ruby187/lib/ruby/gems/1.8/gems/railties-3.0.3/lib/ > rails/engine.rb:138:in `eager_load!'' > from C:/Ruby187/lib/ruby/gems/1.8/gems/railties-3.0.3/lib/ > rails/engine.rb:137:in `each'' > from C:/Ruby187/lib/ruby/gems/1.8/gems/railties-3.0.3/lib/ > rails/engine.rb:137:in `eager_load!'' > from C:/Ruby187/lib/ruby/gems/1.8/gems/railties-3.0.3/lib/ > rails/engine.rb:135:in `each'' > from C:/Ruby187/lib/ruby/gems/1.8/gems/railties-3.0.3/lib/ > rails/engine.rb:135:in `eager_load!'' > from C:/Ruby187/lib/ruby/gems/1.8/gems/railties-3.0.3/lib/ > rails/application.rb:108:in `eager_load!'' > from C:/Ruby187/lib/ruby/gems/1.8/gems/railties-3.0.3/lib/ > rails/application/finisher.rb:41 > from C:/Ruby187/lib/ruby/gems/1.8/gems/railties-3.0.3/lib/ > rails/initializable.rb:25:in `instance_exec'' > from C:/Ruby187/lib/ruby/gems/1.8/gems/railties-3.0.3/lib/ > rails/initializable.rb:25:in `run'' > from C:/Ruby187/lib/ruby/gems/1.8/gems/railties-3.0.3/lib/ > rails/initializable.rb:50:in `run_initializers'' > from C:/Ruby187/lib/ruby/gems/1.8/gems/railties-3.0.3/lib/ > rails/initializable.rb:49:in `each'' > from C:/Ruby187/lib/ruby/gems/1.8/gems/railties-3.0.3/lib/ > rails/initializable.rb:49:in `run_initializers'' > from C:/Ruby187/lib/ruby/gems/1.8/gems/railties-3.0.3/lib/ > rails/application.rb:134:in `initialize!'' > from C:/Ruby187/lib/ruby/gems/1.8/gems/railties-3.0.3/lib/ > rails/application.rb:77:in `send'' > from C:/Ruby187/lib/ruby/gems/1.8/gems/railties-3.0.3/lib/ > rails/application.rb:77:in `method_missing'' > from C:/Users/Family/workspace/jdrampage/config/environment.rb: > 5 > from C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/ > custom_require.rb:31:in `gem_original_require'' > from C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/ > custom_require.rb:31:in `require'' > from ./test_helper.rb:2 > from C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/ > custom_require.rb:31:in `gem_original_require'' > from C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/ > custom_require.rb:31:in `require'' > from unit/article_test.rb:1 > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Colin Law
2010-Dec-15 09:02 UTC
Re: Having trouble testing :( "superclass mismatch" and can''t load "test_helper"
On 15 December 2010 03:43, daze <dmonopoly10-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I''m having trouble testing my Rails 3 application. Unit testing > doesn''t work. If I try ruby article_test.rb directly, I get a "no > such file to load" error, and if I try rake test:units or ruby unit/ > article_test.rb I get this odd "superclass mismatch for class > ArticlesController" error! > > I''m hoping I can get this settled... > My test files were generated by the generator... > > C:\Users\Family\workspace\jdrampage\test\unit>ruby article_test.rbIf you want to run a test directly like this you have to tell it to include the test directory so it can find the helpers, so from the root of your app ruby -I test test/unit/article_test.rb That is a capital i (for Include) Colin -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
daze
2010-Dec-16 05:07 UTC
Re: Having trouble testing :( "superclass mismatch" and can''t load "test_helper"
On Dec 15, 4:02 am, Colin Law <clan...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> If you want to run a test directly like this you have to tell it to > include the test directory so it can find the helpers, so from the > root of your app > ruby -I test test/unit/article_test.rb > > That is a capital i (for Include) > > ColinOkay - I guess that solves one of my problems in which I got the "no such file to load -- test_helper" error. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
daze
2010-Dec-16 05:09 UTC
Re: Having trouble testing :( "superclass mismatch" and can''t load "test_helper"
On Dec 14, 10:58 pm, David Kahn <d...-rfEMNHKVqOwNic7Bib+Ti1W1rNmOCjRP@public.gmane.org> wrote:> Did you look at your ArticlesController for clues?Um...yes. But I didn''t see anything odd.> Also, does your app function through the browser but not running the tests?Yes, running rails server works fine. It''s the tests that give this error.> Would not hurt to copy your ArticlesController here, and maybe also your > Environment.rbOkay. I''m in Rails 3, though, so environment.rb is probably useless to look at... Here''s the articles controller: class ArticlesController < ApplicationController # GET /articles # GET /articles.xml def index @articles = Article.all(:limit => 6) respond_to do |format| format.html # index.html.erb format.xml { render :xml => @articles } end end # GET /articles/1 # GET /articles/1.xml def show @article = Article.find(params[:id]) @section = @article.section respond_to do |format| format.html # show.html.erb format.xml { render :xml => @article } end end # GET /articles/new # GET /articles/new.xml def new @article = Article.new respond_to do |format| format.html # new.html.erb format.xml { render :xml => @article } end end # GET /articles/1/edit def edit @article = Article.find(params[:id]) end # POST /articles # POST /articles.xml def create @article = Article.new(params[:article]) respond_to do |format| if @article.save flash[:notice] = ''Article was successfully created.'' format.html { redirect_to(@article) } format.xml { render :xml => @article, :status => :created, :location => @article } else format.html { render :action => "new" } format.xml { render :xml => @article.errors, :status => :unprocessable_entity } end end end # PUT /articles/1 # PUT /articles/1.xml def update @article = Article.find(params[:id]) respond_to do |format| if @article.update_attributes(params[:article]) flash[:notice] = ''Article was successfully updated.'' format.html { redirect_to(@article) } format.xml { head :ok } else format.html { render :action => "edit" } format.xml { render :xml => @article.errors, :status => :unprocessable_entity } end end end # DELETE /articles/1 # DELETE /articles/1.xml def destroy @article = Article.find(params[:id]) @article.destroy respond_to do |format| format.html { redirect_to(articles_url) } format.xml { head :ok } end end end I hope this helps. Though this class is pretty standard... -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
daze
2010-Dec-21 02:43 UTC
Re: Having trouble testing :( "superclass mismatch" and can''t load "test_helper"
I figured it out. I simply forgot to put "Admin::" for the articles controller in the admin namespace. Making the controllers start with "class Admin::ArticlesController" resolved the issue. Of course I had to add "Admin:: to any other controllers in the admin namespace that were missing it too. :) -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.