Shoulda Matchers 2.0

Jason Draper

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?