RSpec 2.13 is released!

Myron Marston

Feb 23, 2013

I’ve just released RSpec 2.13. It’s a minor release containing a few backward-compatible enhancements and lots of bug fixes. It is a recommended upgrade for all users.

Thanks to all the contributors who helped make this RSpec release happen.

Notable New Features

Profile more than 10 examples

RSpec has featured a --profile option for a long time. It dumps a report of the 10 slowest examples. Now you can pass a numeric option to have it print more than 10 examples.

To print off the 15 slowest examples, you could use:

rspec --profile 15

let and subject declarations can use super

Users have requested this for a while. This allows to override a let or subject declaration in a nested group while delegating to the original definition from the parent group. Just use super():

describe Array do
  let(:numbers) { [1, 2, 3, 4] }

  context "when evens are filtered out" do
    let(:numbers) { super().reject(&:even?) }
  end
end

Note that to use this feature, you must use explicit parens in the call to super; otherwise ruby will give you an ugly implicit argument passing of super from method defined by define_method() is not supported error.

be_within matcher supports percent deltas

This is best illustrated by an example:

# The existing `be_within` matcher (which still works):
expect(account.balance).to be_within(10).of(500)

# Now you can do this, too:
expect(account.balance).to be_within(2).percent_of(500)

include matcher can accept a list of matchers

This is handy when you want to verify something about the items in a list rather that simply verifying the items’ identity.

RSpec::Matchers.define :a_user_named do |name|
  match do |user|
    user.name == name
  end
end

expect(users).to include(a_user_named("Coen"), a_user_named("Daphne"))

Docs

RDoc

Cucumber Features

Release Notes

rspec-core 2.13.0

Full Changelog

Enhancements

Bug fixes

rspec-expectations 2.13.0

Full Changelog

Enhancements

Bug fixes

rspec-mocks 2.13.0

Full Changelog

Bug fixes

rspec-rails 2.13.0

Full Changelog

Enhancements