Bugs: Browse | Submit New | Admin

[#5990] Inheritance and Autorunner: Default_test causes a problem

Date:
2006-10-02 17:05
Priority:
3
Submitted By:
M B (mrbright)
Assigned To:
Ryan Davis (zenspider)
Category:
Misc / Other Standard Library
State:
Closed
Platform:
 
Summary:
Inheritance and Autorunner: Default_test causes a problem

Detailed description
I have created an inherited TestCase object.  When running the TestSuite with -n /Regexp/ Ruby pukes.  
The error:
f:/ruby/lib/ruby/1.8/test/unit/autorunner.rb:132:in `=~': cannot convert Symbol
into String (TypeError)
        from f:/ruby/lib/ruby/1.8/test/unit/autorunner.rb:134:in `options'
        from f:/ruby/lib/ruby/1.8/test/unit/autorunner.rb:132:in `[]'
        from f:/ruby/lib/ruby/1.8/test/unit/collector.rb:26:in `include?'
        from f:/ruby/lib/ruby/1.8/test/unit/collector.rb:25:in `each'
        from f:/ruby/lib/ruby/1.8/test/unit/collector.rb:25:in `include?'
        from f:/ruby/lib/ruby/1.8/test/unit/collector.rb:18:in `add_suite'
        from f:/ruby/lib/ruby/1.8/test/unit/collector.rb:18:in `find_all'
        from f:/ruby/lib/ruby/1.8/test/unit/collector.rb:18:in `each'
         ... 7 levels...
        from f:/ruby/lib/ruby/1.8/test/unit/autorunner.rb:194:in `run'
        from f:/ruby/lib/ruby/1.8/test/unit/autorunner.rb:14:in `run'
        from f:/ruby/lib/ruby/1.8/test/unit.rb:285
        from f:/ruby/lib/ruby/1.8/test/unit.rb:283


The actual Code is:
autorunner.rb: line 132 
  Was:  @filters << proc{|t| n =~ t.method_name ? true : nil}
  Changed: @filters << proc{|t| n =~ t.method_name.to_s ? true : nil}

When I would run the thing, I found that the default_test method, which I am consequently refusing to run but overwriting
my class, it would return a Class type of "Symbol".  By putting in the .to_s method call, the system is then
able to compensate appropriately.

I hope this makes sense.

My Inherited class overwrites the Run method with the following:
  def run(*args) #:nodoc:
    return if @method_name.to_s == "default_test"
    super
  end  

I do this so that I can exclude the default_test object from my class.

Thanks for a great product!

Add A Comment: Notepad

Please login


Followup

Message
Date: 2007-03-21 19:28
Sender: Ryan Davis

the standard way of doing this is a much simpler:

undef_method :default_test
Date: 2006-11-02 16:04
Sender: M B

I am providing a Series of files that will demonstrate what
I am talking about.

The File: rubyExample.tar.gz - 
  md5sum: c8406ea43910b2483adf7729f62214d6
To demonstrate:
  ruby trial.rb -n /01/
Date: 2006-11-02 06:40
Sender: Ryan Davis

Please provide a minimally reproducible test case.

Attached Files:

Name Description Download
rubyExample.tar.gz Example of said bug. Download

Changes:

Field Old Value Date By
status_idOpen2007-03-21 19:28zenspider
close_date2007-03-21 19:282007-03-21 19:28zenspider
File Added914: rubyExample.tar.gz2006-11-02 16:04mrbright
category_idLanguage / Runtime / Core Libraries2006-11-02 06:40zenspider
assigned_tonone2006-11-02 06:40zenspider