Forum: Ruby something_test.rb instead of test_something.rb with autotest

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
31e038e4e9330f6c75ccfd1fca8010ee?d=identicon&s=25 Gregory Brown (Guest)
on 2007-04-29 21:19
(Received via mailing list)
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
Ec07fbda510a142f5331ffd903b07820?d=identicon&s=25 Gordon Thiesfeld (Guest)
on 2007-04-29 22:40
(Received via mailing list)
> 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.
31e038e4e9330f6c75ccfd1fca8010ee?d=identicon&s=25 Gregory Brown (Guest)
on 2007-04-29 22:56
(Received via mailing list)
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...
Ec07fbda510a142f5331ffd903b07820?d=identicon&s=25 Gordon Thiesfeld (Guest)
on 2007-04-30 14:35
(Received via mailing list)
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
31e038e4e9330f6c75ccfd1fca8010ee?d=identicon&s=25 Gregory Brown (Guest)
on 2007-04-30 15:21
(Received via mailing list)
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
This topic is locked and can not be replied to.