[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

something_test.rb instead of test_something.rb with autotest?

Gregory Brown

4/29/2007 7:19:00 PM

I recently swapped Ruport's tests to be named something_test.rb
instead of test_something.rb

Is there a quick config option I can throw in so this doesn't break autotest?

Warm Regards,
gregory

4 Answers

Gordon Thiesfeld

4/29/2007 8:40:00 PM

0

> Is there a quick config option I can throw in so this doesn't break autotest?

I think if you require 'autotest/fixtures' in your .autotest file it
should do this. If not, then you should be able to figure out how
from looking at fixtures.rb.


Gregory Brown

4/29/2007 8:56:00 PM

0

On 4/29/07, Gordon Thiesfeld <gthiesfeld@gmail.com> wrote:
> > Is there a quick config option I can throw in so this doesn't break autotest?
>
> I think if you require 'autotest/fixtures' in your .autotest file it
> should do this. If not, then you should be able to figure out how
> from looking at fixtures.rb.

Is this a rails specific thing? I'm not working within rails.

I ended up getting all of this:

seltzer:~/devel/ruport/ruport/trunk sandal$ autotest
/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:99:
warning: /usr/local/lib/ruby/gems/1.8/gems/ZenTest-3.4.3/bin/autotest/fixtures:
Not a directory
/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:99:
warning: /usr/local/lib/ruby/gems/1.8/gems/ZenTest-3.4.3/bin/autotest/fixtures.rb:
Not a directory
/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:99:
warning: /usr/local/lib/ruby/gems/1.8/gems/ZenTest-3.4.3/bin/autotest/fixtures.rbw:
Not a directory

I'll need to look at the file more closely, but I'm not sure if this
was what I was looking for...

Gordon Thiesfeld

4/30/2007 12:34:00 PM

0

This worked for me on ZenTest 3.5.1. Hope it helps.

# in .autotest
# You need to change the test_mappings accessor to look for the
different file name

Autotest.add_hook :initialize do |at|
at.test_mappings = {
/^lib\/.*\.rb$/ => proc { |filename, _|
at.files_matching %r%^test/#{File.basename(filename).gsub '_',
'_?'}.*$%
},
/^test\/.*_test\.rb$/ => proc { |filename, _|
filename
}
}
end

# Then you need to modify the path_to_classname method, otherwise it
will look for TestClassTest instead of TestClass

Autotest.send(:define_method, :path_to_classname) do |s|
sep = File::SEPARATOR
f = s.sub(/^test#{sep}/, '').sub(/\.rb$/, '').split(sep)
f = f.map { |path| path.split(/_/).map { |seg|
seg.capitalize }.join }
f = f.map { |path| path =~ /^Test/ ? path :
"Test#{path.gsub('Test','')}" }
f.join('::')
end


Gregory Brown

4/30/2007 1:21:00 PM

0

On 4/30/07, Gordon Thiesfeld <gthiesfeld@gmail.com> wrote:
> This worked for me on ZenTest 3.5.1. Hope it helps.

that gets me most of the way there, I still need to play with the file
mappings as it's not picking up changes to the files, only the tests.

Thanks though, this should get me where I need to be!

-greg