Archive for the ‘tests’ Category

A Bit of DRYness for Unit Tests in Rails

Friday, January 13th, 2006

A Bit of DRYness for Unit Tests in Rails

> After spending way too much time writing these nearly identical tests over and over again for each of my test cases, I finally got around to refactoring the idiom out into a couple of class methods on Test::Unit::TestCase itself.

Simplify your Rails Unit Tests

Friday, January 13th, 2006

Simplify your Rails Unit Tests

> So you’ve spent a few weeks writing your Ruby on Rails application, and then you realize you’ve been spending all of your time learning about this awesome language and web development framework, and all of the automagically generated unit tests that Rails makes for you are really just stubs. Damn. You sit down and start coding, but you realize you’re writing variations on a theme: check to see if a model creates/updates/destroys correctly, etc. etc. You remember something DHH said about a TLA… that’s right! DRY!

Testing with Rails

Tuesday, November 29th, 2005

A hint with writing tests with Ruby on Rails.  If you are using fixtures, the name of the fixture is the name of the database table, not the name of the model under test.

For instance, this code:

class TaskTest < Test::Unit::TestCase
  fixtures :tbl_task

The symbol :tbl_task is the name of the database table.