This week in open source

Mike Burns

Since last week was Thanksgiving here in the States, here’s a double-whammy: everything that happened last week and everything that’s happened this week, in one blog post!


The big deal with suspenders, our app app, is that version 0.3.2 is officially out! Since 0.3.1 on October 28th we’ve added an email validator, raised email delivery errors in the development environment, added Heroku support (try the --heroku flag), and switched to bundler for the gem itself.

While Dan Croak (croaky) was releasing 0.3.2 (40690ae) he also made sure to document the --heroku and --clearance flags (02a8bb0). Gabe Berke-Williams (gabebw) added a missing bundler/setup to the Rakefile, tying everything together neatly (d09ee5b).

shoulda-matchers, shoulda, high_voltage, bourne, pacecar, flutie, shoulda-context, factory_bot-rails

Above I mentioned how Gabe Berke-Williams (gabebw) added bundler/setup to the Rakefile of suspenders. He also did it to shoulda-matchers (9d79124), shoulda (8054563), high_voltage (ec656e1), bourne (9d21677), flutie (7863d14), shoulda-context (75a8384), factorybotrails (797a985), and pacecar of all things (fb972c0).



Version 1.2.0 of bourbon is out, bringing more Sass mixins into your life. Phil LaPier (plapier) added support for the CSS3 appearance (e888e0a) and background-size (4588c5c) properties, and added $georgia, $helvetica, $lucida-grande, and $verdana variables (4ba1cff). He also updated the docs to reflect this (d23064b), cleaned up some warnings (99946bb), and made the release (93beb25).


The past two weeks saw an improvement for gem authors in paperclip: Mike Burns (mike-burns) removed the Paperclip::Options object, replacing it with a Hash. Any option you pass to has_attached_file is thus available to your underlying Paperclip extension without any extra work and with a canonical interface (5a7769b).

Prem Sichanugrist (sikachu) continued on his quest for having Paperclip work on CI with Rubinius; he tried removing the generated rbc files so the CI server will generate them every time ([2c08152]( “Remove the compiled .rbc file from Rubinius so it will regenerate

This will fix the problem on the CI server, where some time the change occurred by ")).


In the past two weeks factory_bot has seen three releases: 2.3.0 (85d4735, 2fdabdb, and 89b9a82), 2.3.1 (e15ae8d), and 2.3.2 (17eacf0). Joshua Clayton (joshuaclayton) has been hard at work, you see.

As a result, dynamic attributes and callbacks in traits are called in the right order, closing #247 ([1eb7e1b]( "Ensure traits and dynamic attributes that are applied evaluate correctly

Closes #247”) and 65e5e25). Also, traits can be added to factories dynamically, when creating an object ([ [:male, :admin] factory :female_admin, :traits => [:admin, :female] end end


You could just create a user with those traits assigned:

FactoryBot.create(:user, :admin, :male)
FactoryBot.create(:user, :admin, :female)

This can be combined with attribute overrides as expected.

FactoryBot.create(:user, :admin, :male,   :name => "John Doe")
FactoryBot.create(:user, :admin, :female, :name => "Jane Doe")">442ba18]( "Traits can be added to factories when the factory creates an instance

This allows for traits to be used with normal factories without having to name every single factory that uses one (or many) traits.

So, instead of creating maleadmin and femaleadmin factories:

FactoryBot.define do
  factory :user do
    trait(:admin)  { admin true }
    trait(:male)   { gender ")). For example, if you have an `:admin` trait you can make an admin user on the fly with `FactoryBot.create(:user, :admin, :name => "Frank Blank")`.

The other pile of commits from Josh are all internal refactorings. Things like removing the Proxy#associate method in place of using Proxy#set everywhere (3ed2f62, f47c03c, and d3a7b7e), cleaning up the require statements (9472a14), consolidating and documenting all exceptions in the FactoryBot class (c46c090), handling nil blocks when running a factory (2bf5cea) and when creating it in general (86f971b), delaying the sorting of attributes until the last minute by using a lighter-weight array instead of hash (d563b94), making bold claims about inheritance that some blog post authors disagree with (557cce6), moving Proxy::Stub#next_id into the private namespace (0c31b6e), taking an ignored argument to a block so some versions of Ruby don’t complain (c93dea5), defaulting the creation method to save instead of nil (5bbbcb9), singularizing Attribute#aliases_for? into Attribute#alias_for? (f247968), using his beloved Null Object pattern to reduce some conditionals (fba404a and b339c8f), adding a common #to_proc method across all attributes and then invoking methods with #[] instead of #call (fba6f33 and 3282eea

This allows for Attribute#toproc to not require a proxy to be passed to return a Proc. It also allows for removal of Attribute#addto")), straight-up removing dead code from the AttributeList (56a6f67), and passing overrides through to the runner class (5fc57da).

Gotta break a lot of eggs to make an omelette. Speaking of, Gabe found a broken version.rb and fixed it (1e47af0).


Another doc week for clearance where Gabe Berke-Williams (gabebw) observed that we test it against Rails 3.1.0 (f7c5e3b) and Matthew Burket (Mab879) noted that you must migrate the database before running rake, when testing (39a6ac5 and 8b9e89b).


New features in our Braintree fake object, appropriately named fake_braintree! Gabe Berke-Williams (gabebw) added support for FakeBraintree.generated_transaction (d1bbcb7, 917a235, 4fc470d, and 4cb5cb0), Braintree::Subscription.update (fab3c92), and Braintree::Customer.delete (c2aa516). Joe Ferris (jferris) started work on add-ons (312cfac).

Gabe also did some lovely documenting; now you can learn about how to use this in Cucumber (c163c4d), how to avoid calling FakeBraintree.activate (dff3e51), whether the build is broken (499cb05 and 1b1a532), and what the difference is between declining and verifying a card (625993a). Additionally the Subscription class was refactored (3ed090e), the tests were made more explicit (a23a61c), and the tests pass (0a12182).

Project name history can be found here.

  1. Looking for FactoryGirl? The library was renamed in 2017.