Hacker News new | past | comments | ask | show | jobs | submit login

The biggest thing from RSpec I've missed since switching from Ruby are the describe/it blocks. I felt like they helped you, as you were writing tests, compose sentences that, in the end, should be true about the system under test. It allowed you to abstract your thinking to a level that was more conducive to understanding the essence of the code/system. I'll agree with you on all the should/be stuff; TestUnit assertions work just fine.



I can't completely agree with both of you regarding assertions.

There's always cases where a test needs to be done on several properties of an object at once (validation of a rails model attribute, for instance, when you want to test that the model is invalid and that the right error message is present) or where the setup to prepare the assertions is quite heavy, I think this is where custom assertions can be quite helpful, first it gives you more meaningful tests, and the reported failures can be more documented than with asserts. In that regard, you can write simpler assertions for each of these tests, and do that for every fields of every models. In the end it's a lot of code duplication that may also lead to errors (tests have to be refactored as much as the tested code).




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: