ZenTest: June 2007 Archives

Ruby Curriculum

| | Comments (10)

I'd like feedback on the following curriculum. I'd especially like to know what you guys think of taking a "test first" approach to teaching a language like ruby. TDD on Week 3. Too early? Students should have some prior knowledge in programming, but not necessarily OO, testing, or dynamic languages. You think it is too much?

RubyCurriculum.pdf (32K)

Personally, I think it'll be a medium sized hurdle that should allow the rest of the quarter to go by a bit smoother. All homework will be test driven, allowing the students to know ahead of time that they're right or wrong.

What do you think?

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.

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.

About this Archive

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

ZenTest: May 2007 is the previous archive.

ZenTest: 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