I have been using ruby exclusively for about a month and I really love it. However, I am having an incredibly hard time using, or even learning TDD. My brain just doesn’t function that way…
I really, really want to learn TDD but to be honest I am a bit confused. All the articles that I find when Googling around are mostly specific to Rails, which is not interesting to me because I want to learn how to do efficient testing for any ruby application, from the simple one-file script to the complicated gem, not for Web apps. Also, there are so many frameworks and so few tutorials to get started.
Could anybody give me any advice on how to learn TDD so that I can at least start to consider myself an aspiring rubyist?
The best way to learn TDD is by just doing it. I suggest you build a new project using TDD. This means don’t write any non-testing code unless you have a failing test.
It will make you think about writing tests: I want to write this code, how do I write a test for it so I can write it.
It will show you the layered nature of testing. Instead of want a name that is required and can’t contain numbers. you’ll first test setting and reading a name, test requiring the name, test it shouldn’t contain numbers, than think if it has more constraints and test those.
Remember: