small medium large xlarge

22 Sep 2012, 23:01
Albert Yu (3 posts)

In the first test code, there is a line:

@assert_equal, actual.status_date.to_s(:db)@

I’m confusing about the symbol @:db@, what’s the meaning at here?

I try to remove it or rename it, the test still pass, it seems like useless at all, isn’t it?

There’s no related description about this symbol, can anyone enlighten me about this?


25 Apr 2013, 11:57
Dawid Stępień (3 posts)

The book describes this symbol as format of date. @to_s@ method is overide by rails core ( ) and therefore it can take an argument. @:db@ symbol is one of the format type. Look here for others.

Another thing is why author used @to_s@ method with format type. The answer is simple: if test fails, it is much clearer to read a human-readable format of date.

You must be logged in to comment