CoffeeScript supports a subset of pattern matching called destructuring assignment. Destructuring assignment uses patterns to extract out the parts of an object during assignment. It’s a simple and elegant technique but when overused can have unintended consequences on a codebase. CoffeeScript’s two data structures, Arrays and Objects, can both be destructured. Let’s first take a …
The Ruby community’s obsession with testing is unrivaled. Over the years, Rubyists have gone from old school TDD using test/unit, to modern BDD with RSpec and finally to comprehensive integration testing, including JavaScript support, via Cucumber. The goal was tests at all layers and to get as close as possible to simulating a real browser. …
In a typical agile project the test suite grows roughly twice as fast as the non-test code. As developers, our goal should be the minimum amount of test code that specifies the behavior of the app. This often leads to using “clever” metaprogramming techniques in order to reduce boilerplate and overall lines of test code. …
As more and more parts of our applications are written in JavaScript, its important to have them covered with automated tests. Fortunately, there are numerous JavaScript testing tools available. As a BDD fan, the RSpec inspired Jasmine is currently my go-to.
After a recent run-in with an irate local sysadmin, I was convinced to try out developing on a virtual machine. His argument was that developing on one platform, such as OS X, when you are deploying to another, such as Linux, was just asking for trouble. Specifically he was referring to using Ruby gems with …
Recently I was introduced to a tool developed by my co-workers called Story Mapper. Story Mapper was inspired by an agile design technique outlined in this post; it involves a way of organizing user stories around activities. During the story writing process each story is given an activity such as “registering” or “administrating” so instead …
Like most developers I previously wrote off RSpec’s view specs entirely and instead decided to exclusively use Cucumber to test drive my views. But after reading the chapter on view specs in the recent RSpec book I decided to give them another try on a recent app. The app was a traditional CMS with an …
In TDD we write tests to discover the interface of the object we’re testing. Mock objects extend TDD by discovering an object’s collaborators. [1] By mocking an object’s collaborators we can truly test an object in isolation. Changes in the implementation of its collaborators, but not their interface, will not cause a test in which …
Over time all software begins to rot. At first a young codebase is small and lean, it’s a pleasure to work on, a single developer may even be able to understand the entire codebase. However, iteration after iteration time constraints and poorly specified features begin to manifest themselves in the codebase. TODOs are everywhere, tests …
In many traditional software development methodologies you write tests for your code after you write your code. TDD reverses this process by requiring you to write your tests before you write your code. By writing your test first you immediately take the viewpoint of a client of the code you are about to write. This …