This week in open source

A somewhat short update this week, in large part because I’m writing this from a different timezone than normal. Next week I’ll be five hours slower, don’t you worry!


New in suspenders, our Rails app generator: a pre-packaged email validator class (b91ea65), which probably mixes well with things like liaison. Also on the email front, delivery errors are a full error in development, which means we can catch errors faster (637427d). Both of these improvements brough to you by Dan Croak (croaky).


The shoulda-matchers collection of RSpec/shoulda matchers has hit 1.0.0! Gabe Berke-Williams (gabebw) made the switch from 1.0.0.beta3 to 1.0.0 (7c408ef), but first removed a deprecation warning from the rdoc generator (c47557c) and simplified the test suite (22740fd).


Another 1.0.0 release for shoulda this week, as shoulda-context, which controversially provides nested test structures for Test::Unit saw an explicit dependency on Test::Unit so that MRI 1.9.2 doesn’t confuse it with MiniTest ([d1c5881]( “Added explicit dependency on test-unit for better Ruby 1.9 support

This will likely be a temporary solution before fully embracing Minitest”))—that’s thanks to Ryan McGeary (rmm5t)—but then Jason Morrison (jasonm) decided that enough was enough and he released version 1.0.0 of shoulda-context (9557425).


Our file uploading gem, paperclip, saw an interesting commit from yours truly, Mike Burns (mike-burns). With a Paperclip attachment you can get the URL (e.g. @user.avatar.url(:medium)). The logic for generating this URL was specified in the Paperclip::Attachment class, which meant that to do anything interesting like delaying the thumbnail generation or storing the style names in the database involved monkey-patching, which is clearly a mistake. So I pulled that functionality out into the UrlGenerator class, but more importantly I parameterized that class name so you can pass whatever you want. For example:

class User < ActiveRecord::Base
  has_attached_file :avatar,
    :url_generator =>

class DataBaseStyledUrlGenerator
  def initialize(db)
    @db = db

  def new(attachment, attachment_options)
    @attachment = attachment
    @attachment_options = attachment_options

  def for(style_name, options)
    dimensions = db.select_row("SELECT width, height FROM styles WHERE style_name = ?", style_name)

Refactoring to add functionality? Heck yeah! (bc5c51d)


A bug fix and the usual slew of refactorings for factory_girl this week. As the bug fix, Joshua Clayton (joshuaclayton) fixed implicit traits’ error output by having them know their name (0124d42). Small, but good to have.

Internally, he applied the null object pattern to act as a parent of orphan factories (aee300a). He added a DeclarationList to hold the collection of things declared about a factory, including attributes (3114dcd and f721bc6). He abstracted out the idea of a factory and a trait into the Definition class (41bc3ac). He also removed the unused @ignored_attributes instance variable (68e8e9e) and moved the logic around adding a proxy value into one place (3803be3).

Alexander Gronemann (Highcode) fixed a typo in the docs for us (5a48129). Thanks!


All changes to the capybara-webkit headless browser were documentation changes this week: Joe Sak (joemsak) mentioned :js => true for specs and that transactional fixtures still cannot be used (true should still be used, and to note the Transactional fixtures gotcha in the main README">eb6165d). Joe Ferris (jferris) took a stance on the inconsistent authors section of the README by specifying his name and Matt Mongeau’s name, but also pointing to the list of Github contributors (8674ef7). While there he changed some grammar to his liking (7be8f94).


Another refactoring-based feature for us this week in clearance, our authentication gem. Constantine Mavromoustakos (cmavromoustakos) split the user instance methods into an InstanceMethods module, which helped them be more selective about which methods they want to pull into their MongoDB-based app (cc0d007).


Mostly refactoring on the Braintree test fakes, fake_braintree, this week, but let’s see what features we can pull out of these refactorings by Gabe Berke-Williams (gabebw). He introduced a FakeBraintree::Subscription class (e4e99f8), which can you use as a fake subscription. He also introduced a FakeBraintree::Customer class, to be a fake paying customer (0259b9d and 9902e08). Maybe you needed those!

On the lighter side he cleared up the test coverage question by removing most untested code (0f6ed3f and ad7a4b9), adding a test to ensure that the next billing date is a month from now (84cfbc4), and removing an 80-line unused method (e1a886c). He responded to my ctags file observation from last week by removing it (8eb5988 and 7a9fb76). He also did a couple of other things under the name “cleanup” (5690d40, 76675cb, 2aaf85c, d7811aa, and cc7463f).