something_test.rb instead of test_something.rb with autotest?

G

Gregory Brown

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
 
G

Gordon Thiesfeld

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.
 
G

Gregory Brown

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...
 
G

Gordon Thiesfeld

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
 
G

Gregory Brown

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,241
Messages
2,571,219
Members
47,850
Latest member
StewartTha

Latest Threads

Top