I generally find that most developers are fairly aware of and willing to apply the DRY principal on their main codebase. However, when I look through people’s tests, I find that the old copy/paste habit has found it’s way into their workflow (again?). I’m using “their code” to save face here…I found this in my own code and started looking for ways to clean it up. So, let’s take a look at an example of how we can remove some duplication from our specs.
I recently started playing around with EmberJS. While I was insanely impressed with how easy it was to get a single-page app up and running, I was having difficulty getting QUnit setup correctly. After some finagling I was able to get it working. In my particular case I’m using Ruby 2.0.0 and Rails 4.0.0, though I’m sure this same setup would work with previous versions with minimal (if any) tweaks.