Rails: June 2007 Archives

I use autotest almost exclusively. It is very rare that I run tests via rake these days so it is embarrassing when something fails via rake and not via autotest. It makes me look bad.

My latest snafu was regarding fixtures. See, the project prepopulates the test db and I started migrating them away from using the fixture calls they were using. When I use my typical rake nuke rule, it'll scrap and rebuild everything, including repopulating the db. autotest is happy as a clam. But rails' test:units does a prepare each time, nuking anything we put in there. I've seen a lot of weird hacks to deal with this, but I just came up with one I finally like:

# ensure we always populate the test db
%w(units functionals integration).each do |type|
  Rake::Task["test:#{type}"].prerequisites.push "db:test:populate"
end

db:test:populate is up to you, do what you need to do. For us, it just ensures we do a db:fixtures:load with RAILS_ENV=test.

This way, no matter HOW you run your tests, either by default rule or by specifying one of the phases you're interested in, you'll always do that populate.

YARR! Thar be mutiny!

| | Comments (6)

zenspider: today be the day
terraalien: Sure is :)
terraalien: I've contemplated picking it back up... but I have a five day old I'd rather spend time with :)
zenspider: fair 'nuff
zenspider: would ye like to craft a hand-off eeee-mail?
terraalien: Sure.

zenspider: yarr matie. ye be sending the email handing over the ship or we mutiny and throw ye overboard!
terraalien: Sorry... it's turned in to a blog post... it is in progress, though, I promise.
zenspider: yarrrrr ruby core don't be readin' yer blog
terraalien: I'll send out an email with a link :)
zenspider: that be acceptable matie

Yarr! We mutiny and be takin' over test/unit!!! She's a saucy wench with too much meat on 'er bones for our taste. Expect an over'aul soon! Savvy?

I just had a bug on autotest get diagnosed by the filer:

"The root cause is that I have "require 'turn'" in my project (which provides prettier Test::Unit output) but Autotest::handleresults isn't designed to parse turn's output."_

This was an advanced issue caused by turn (I do hope he files a bug against turn), and solved simply be removing it.

I've seen much simpler issues that can be nearly as confusing. For example, several projects I've worked on that generated thumbnails or index files in RAILS_ROOT, triggering autotest to rerun. This can be confusing, but there is an easy way to figure this stuff out. Run autotest -v and it'll tell you what file changes it detected before rerunning... Then it is a matter of changing your code or adding a .autotest like so:

Autotest.add_hook :run do  |at|
  at.exceptions = /^(?:\.\/)?(?:db|doc|log|public|script|tmp|filestore|vendor\/r
ails)|\.svn|(?:.*_flymake\.rb$)/
end

Ugly... I know. I'll come up with a more flexible means of adding a single exclusion.

Heckle is a mutation tester. It modifies your code and runs your tests to make sure they fail. The idea is that if code can be changed and your tests don't notice, either that code isn't being covered or it doesn't do anything.

Changes:

1.4.1 / 2007-06-05

  • 3 bug fixes:

    • Add zentest as a heckle dependency. Closes #10996
    • Fixed heckling of call with blocks.
    • Fix testunitheckler's test_pass? so it returns the result of the run rather than ARGV.clear
  • http://www.rubyforge.org/projects/seattlerb

About this Archive

This page is a archive of entries in the Rails category from June 2007.

Rails: May 2007 is the previous archive.

Rails: July 2007 is the next archive.

Find recent content on the main index or look in the archives to find all content.

Pages

Powered by Movable Type 4.1