Something_test.rb instead of test_something.rb with autotest

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

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.

On 4/29/07, Gordon T. [email protected] 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…

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

On 4/30/07, Gordon T. [email protected] 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