Posts

Showing posts with the label tests

A Bit of DRYness for Unit Tests in Rails

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

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

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.