Unit testing date columns


#1

I’m trying to run my first tests, following along the tute in Agile Web
Dev with rails book.

I have a table with a created_at timestamp column in mysql.

My test always fails when testing the result of the created_at column.
The book says my test should look like:
assert_equal “2006-03-09 21:01:37”,
@thing.date_available_before_type_cast

but when I run my test I get 1 error returned:
“undefined method date_available_before_type_cast”

what am I doing wrong?


#2

There is an undefined method because your @thing has no date_available
method.

You only need to add the _before_type_cast suffix to make it work.

Mark