giant robots smashing into other giant robots

Written by thoughtbot

drapergeek

Shoulda Matchers 2.0

Shoulda Matchers has been around for a long time. Unfortunately, it’s starting to suffer from feature bloat so we’re narrowing its focus to keep releases fast and the maintenance burden low.

Removing Deprecated Matchers

The following matchers were deprecated in 1.5 and will be removed in 2.0 . If you’re currently using these methods you should consider testing the code in another way.

assign_to

The assign_to matcher allows you to ensure you have set an instance variable properly. We do not use this because we typically cover those types of assertions implicitly through an integration test. An integration test may be slower than a unit test, but it provides more thorough coverage.

validate_format_of

The validate_format_of matcher allows you to perform the same operation as the allow_value matcher. Please use the allow_value matcher instead.

should validate_format_of(:email).with('user@example.com')
should allow_value('user@example.com').for(:email )

have_sent_email

We recommend email-spec for testing emails in your apps. It has the added benefit of working with your integration suite as well as your unit tests.

respond_with_content_type

The respond_with_content_type matcher is not a matcher we use often. This behavior can be tested using the response object in your controller tests without the need for a matcher.

query_the_database

We do not have a recommended solution for a replacement on this matcher.

Matchers Removed Temporarily

The strong_parameters and delegate matchers will also be removed in 2.0. We ran into some trouble implementing them but hope to re-implement them in a less troublesome way soon.

New Hotness

As part of the move to 2.0, we will also be dropping support for Rails 2 & ruby 1.8. We will continue to support Rails 3.x and ruby 1.9.x and will be adding support for ruby 2.0 soon.

Keeping it tight

We are trying to keep Shoulda Matchers a tight focused gem and make sure the matchers we do support are as robust and thorough as possible. Do you think there are any other matchers we should remove?

Written by Jason Draper.

gabebw

This week in open source

factory_girl

There’s a new version of factory_girl this week, as usual: 3.1.1 (aa81d2f).

Mark Rushakoff (mark-rushakoff) fixed a typo (4682ab0). Have I mentioned how much I love documentation fixes? Because I do.

Joshua Clayton (joshuaclayton) ensured that FactoryGirl.attributes_for works with has_many associations (50be545). He also refactored Strategies to be modules instead of classes, and added an Evaluation façade to make building strategies easier (89d5e94).

flutie

flutie got some love this week from Edwin Morris (ehmorris), who changed values from pixels to ems (fd26ed0) and these new-fangled CSS3 “rems”. REMs are relative to the base element’s size, not to the parent’s size (more here). I wish I’d had that back in the day.

paperclip

paperclip got a bunch of bug fixes from Prem Sichanugrist (sikachu). He fixed the content_type validator to allow blanks and nils (5eed1dc), ensured that code dealt with the content type, not the MimeType (3f1d30f), closed ALL the files (4f6d482), and removed unused code (yay!) (02eb725).

Sebastien Guignot (sguignot) fixed attachment.reprocess! when using Fog or S3 (9d1355b).

Kir Maximov (kir) fixed a problem with an incorrect content_type (3e98fc2).

shoulda-matchers

shoulda-matchers continues to improve. Gabe Berke-Williams (gabebw - that’s me!) added tests for Rails 3.2 (aff2824) and bumped rspec-rails (5baa056). As ever, the NEWS file is the place to watch for updates to functionality.

Aaron Gibralter (agibralter) fixed the ensure_length_of matcher to check for all possible I18n error messages (0a8e652), meaning our internationalized users aren’t left with false negatives in their tests.

Victor Pereira (vpereira) added the in_array method (e40e2cb) to the ensure_inclusion_of matcher, meaning you can do it { should ensure_inclusion_of(:attribute).in_array(%w[cat dog]) now.

lolconomy

This week in open source

bourbon

So this bourbon gem…people seem to like it: there was a RailsCast about it and the principle author (Phil LaPier) will be speaking at Frontend United about it.

This week people cleaned up the obsolete CSS attributes: Thibaut (Thibaut) removed -moz-inline-block (d73ea46), Chad Mazzola removed both -ms-border-radius and -o-border-radius (10a5908), and Phil LaPier (plapier) removed -moz-box-orient (6331e26). Gabe Berke-Williams (gabebw) fixed support for Rails 2 (eacd5ee and e9347e7) and, lesson learned, removed Gemfile.lock (671ad33).

factory_girl

Version 2.6.3 of factory_girl is out, all y’all. In this action-packed version we got a cucumber step named e.g. Given the following post exists (note the lack of : at the end), via cj (cj) (d4b8cac and 48afe24). Barun Singh (barunio) fixed a bug where the factory’s traits weren’t compiled in the very first time the factory was used (68ca50f), plus a factory can use all the traits on any ancestor (f14a8cf). Joshua Clayton (joshuaclayton) is now listed as an author (07d2834), so congrats to him and his hard work. As part of that hard work he discovered that the vintage syntax broke in MRI 1.9.2-p318, and then fixed it (a7acc3e).

This just in! Version 3.0.0.rc1 is now public! It breaks everything, again! Please try it and open issues with what breaks:

gem 'factory_girl', '3.0.0.rc1'

bourne

Oh hey version 1.1.1 of bourne is out (650afb0)! Bourne is an extension to mocha that adds test spies so your tests can read like normal tests. Tristan Dunn (tristandunn) added support for mocha 0.10.5 (286d8f9) and fixed a long-standing error message that occurs when you forget to stub a method before spying on it (17dc7d2).

Gabe Berke-Williams (gabebw), who pushed the release, also did some maintainance: adding Travis CI notifications to the README (7d6eb37), removing Gemfile.lock (950a445), and some general code cleanups (4bbe610 and b0f1f99).

shoulda-matchers

The big deal in shoulda-matchers over the past week was when Fujimura Daisuke (fujimura) added the ability to specify the key for the flash message in the set_the_flash matcher (0e0339e, ef866e2, and fd4aa53):

it { should set_the_flash[:alert].to("Password doesn't match") }

Gabe Berke-Williams (gabebw) did his usual maintainance of converting the docs to use Markdown (85c37c4), cleaning up the ModelBuilder that’s used in the tests (31595b0), and showing off how often our build is broken in the README using Travis CI (eebb806), which he also did to shoulda proper (7d805d0).

cocaine

Also victim to the Travis CI treatment was cocaine, via Gabe Berke-Williams (gabebw) again (ac47b6f and 490c406).

paperclip

The paperclip project is gearing up for a groundbreaking (maybe app-breaking?) release, but in the meantime Mike Boone (boone) fixed an infinitely-growing PATH environment variable (06d69af) while Mike Burns (mike-burns)—also known as: me—totally broke backward compatibility by changing the default :path and :url configuration setting (26f4d40). These new settings avoid overwriting files on different models and also scales to more than 1024 instances of the same model.

capybara-webkit

In capybara-webkit news, Joe Ferris (jferris) controversially allowed the user to interact with invisible elements (02f2a8a), and caught the fact that Capybara.timeout is deprecated (4d954b7).