rspec-2.11.0 is out and filled with a bunch of new features. Big thanks to all who contributed, especially Justin Ko, Andy Lindeman (the newest addition to the RSpec core team) and Myron Marston for their great job addressing issues and shepherding pull requests.
Thanks also to Myron for all his work on two great new features: the new expectation syntax and support for stubbing constants.
rspec-core-2.11.0
Enhancements
- Support multiple
--example
options. (Daniel Doubrovkine @dblock) - Named subject e.g.
subject(:article) { Article.new }
- see http://blog.davidchelimsky.net/2012/05/13/spec-smell-explicit-use-of-subject/ for background.
- thanks to Bradley Schaefer for suggesting it and Avdi Grimm for almost suggesting it.
config.mock_with
andconfig.expect_with
yield custom config object to a block if given- aids decoupling from rspec-core’s configuation
include_context
andinclude_examples
support a block, which gets eval’d in the current context (vs the nested context generated byit_behaves_like
).- Add
config.order = 'random'
to thespec_helper.rb
generated byrspec --init
. - Delay the loading of DRb (Myron Marston).
- Limit monkey patching of
describe
onto just the objects that need it rather than every object in the system (Myron Marston).
Bug fixes
- Support alternative path separators. For example, on Windows, you can now do
this:
rspec spec\subdir
. (Jarmo Pertman @jarmo) - When an example raises an error and an after or around hook does as well, print out the hook error. Previously, the error was silenced and the user got no feedback about what happened. (Myron Marston)
--require
and-I
are merged among different configuration sources (Andy Lindeman)- Delegate to mocha methods instead of aliasing them in mocha adapter.
rspec-expectations-2.11.0
Enhancements
- Expand
expect
syntax so that it supports expections on bare values in addition to blocks (Myron Marston). - Add configuration options to control available expectation syntaxes
(Myron Marston):
RSpec.configuration.expect_with(:rspec) { |c| c.syntax = :expect }
RSpec.configuration.expect_with(:rspec) { |c| c.syntax = :should }
RSpec.configuration.expect_with(:rspec) { |c| c.syntax = [:should, :expect] }
RSpec.configuration.add_should_and_should_not_to Delegator
Bug fixes
- Allow only
Numeric
values to be the “actual” in thebe_within
matcher. This prevents confusing error messages. (Su Zhang @zhangsu) - Define
should
andshould_not
onBasicObject
rather thanKernel
on 1.9. This makesshould
andshould_not
work properly withBasicObject
-subclassed proxy objects likeDelegator
. (Myron Marston)
rspec-mocks-2.11.0
Enhancements
- expose ArgumentListMatcher as a formal API
- supports use by 3rd party mock frameworks like Surrogate
- Add
stub_const
API to stub constants for the duration of an example (Myron Marston).
Bug fixes
- Fix regression of edge case behavior.
double.should_receive(:foo) { a }
was causing a NoMethodError whendouble.stub(:foo).and_return(a, b)
had been setup before (Myron Marston). - Infinite loop generated by using
any_instance
anddup
. (Sidu Ponnappa @kaiwren) double.should_receive(:foo).at_least(:once).and_return(a)
always returns a even if:foo
is already stubbed.- Prevent infinite loop when interpolating a null double into a string
as an integer (
"%i" % double.as_null_object
). (Myron Marston) - Fix
should_receive
so that null object behavior (e.g. returning self) is preserved if no implementation is given (Myron Marston). - Fix
and_raise
so that it raisesRuntimeError
rather thanException
by default, just like ruby does. (Andrew Marshall)
rspec-rails-2.11.0
Enhancements
- The generated
spec/spec_helper.rb
setsconfig.order = "random"
so that specs run in random order by default. - rename
render_template
tohave_rendered
(and alias torender_template
for backward compatibility)
Bug fixes
- “uninitialized constant” errors are avoided when using using gems like
rspec-rails-uncommitted
that defineRspec::Rails
beforerspec-rails
loads (Andy Lindeman)