# Something\_test.rb instead of test\_something.rb with autotest

**URL:** <https://www.ruby-forum.com/t/something-test-rb-instead-of-test-something-rb-with-autotest/93236>\
**Category:** Ruby\
**Created:** [April 29, 2007, 9:19pm UTC](https://www.ruby-forum.com/t/something-test-rb-instead-of-test-something-rb-with-autotest/93236 "2007-04-29T21:19:30Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![naething](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/e47774/32.png) [@naething](https://www.ruby-forum.com/u/naething)\
**Post date:** [April 29, 2007, 9:19pm UTC](https://www.ruby-forum.com/t/something-test-rb-instead-of-test-something-rb-with-autotest/93236/1 "2007-04-29T21:19:30Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![naething](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/e47774/32.png) [@naething](https://www.ruby-forum.com/u/naething)\
**Post date:** [April 29, 2007, 10:40pm UTC](https://www.ruby-forum.com/t/something-test-rb-instead-of-test-something-rb-with-autotest/93236/2 "2007-04-29T22:40:35Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![naething](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/e47774/32.png) [@naething](https://www.ruby-forum.com/u/naething)\
**Post date:** [April 29, 2007, 10:56pm UTC](https://www.ruby-forum.com/t/something-test-rb-instead-of-test-something-rb-with-autotest/93236/3 "2007-04-29T22:56:37Z")

</div>

On 4/29/07, Gordon T. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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…

---

<div class="post-metadata">

**Author:** ![naething](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/e47774/32.png) [@naething](https://www.ruby-forum.com/u/naething)\
**Post date:** [April 30, 2007, 2:35pm UTC](https://www.ruby-forum.com/t/something-test-rb-instead-of-test-something-rb-with-autotest/93236/4 "2007-04-30T14:35:36Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![naething](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/e47774/32.png) [@naething](https://www.ruby-forum.com/u/naething)\
**Post date:** [April 30, 2007, 3:21pm UTC](https://www.ruby-forum.com/t/something-test-rb-instead-of-test-something-rb-with-autotest/93236/5 "2007-04-30T15:21:41Z")

</div>

On 4/30/07, Gordon T. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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
