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
--exampleoptions. (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_withandconfig.expect_withyield custom config object to a block if given- aids decoupling from rspec-core’s configuation
include_contextandinclude_examplessupport 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.rbgenerated byrspec --init. - Delay the loading of DRb (Myron Marston).
- Limit monkey patching of
describeonto 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)
--requireand-Iare 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
expectsyntax 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
Numericvalues to be the “actual” in thebe_withinmatcher. This prevents confusing error messages. (Su Zhang @zhangsu) - Define
shouldandshould_notonBasicObjectrather thanKernelon 1.9. This makesshouldandshould_notwork 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_constAPI 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_instanceanddup. (Sidu Ponnappa @kaiwren) double.should_receive(:foo).at_least(:once).and_return(a)always returns a even if:foois 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_receiveso that null object behavior (e.g. returning self) is preserved if no implementation is given (Myron Marston). - Fix
and_raiseso that it raisesRuntimeErrorrather thanExceptionby default, just like ruby does. (Andrew Marshall)
rspec-rails-2.11.0
Enhancements
- The generated
spec/spec_helper.rbsetsconfig.order = "random"so that specs run in random order by default. - rename
render_templatetohave_rendered(and alias torender_templatefor backward compatibility)
Bug fixes
- “uninitialized constant” errors are avoided when using using gems like
rspec-rails-uncommittedthat defineRspec::Railsbeforerspec-railsloads (Andy Lindeman)