When I started the application I was very new to both Ruby and Rails. The tests I wrote were OK. They worked, they tested the code, but they weren’t very good. All of the tests ended up being request specs using RSpec and Capybara. They were very slow; fifty tests ran at around 200 seconds. In the last few months I have learned a lot about Rails. The application itself has been updated incrementally to reflect what I have learned, but the tests were neglected. It was time for a change.
Test Driven Development (TDD) is a method used to write code more efficiently by writing tests (a small amount of code that makes sure your code is working properly) first. The benefits of writing tests are huge. When a test fails you will usually get an error pointing out exactly what is wrong and where to find the problem. This can be exploited to make the development process easier.
In my Rails projects I use the Haml markup language over the stock ERB language as much as possible. The “markup haiku” that is Haml is much easier to write and maintain. It does have a few quirks, but overall my views have been cleaner and easier to read than the ERB equivalents.
The syntax is dead simple. No more unnecessary end tags or wrapping lines of Ruby in special ERB tags.
Last night I achieved flow. Wikipedia defines flow as “the mental state of operation in which a person in an activity is fully immersed in a feeling of energized focus, full involvement, and success in the process of the activity”. Flow is that state of mind you’re in when you sit down to play a game or write some code and look up five minutes later to find that you just stayed up the whole night. Flow is to be truly focused.