RSpec 2.99 and 3.0 RC1 have been released!
Myron Marston
May 18, 2014The RSpec team has released 3.0.0.rc1 and 2.99.0.rc1! Barring a new major issue being reported, this will be the last prerelease, and we’ll release 2.99.0 and 3.0.0 final in 2 weeks.
If you’re upgrading a project from 2.x, check out the upgrade instructions.
If you’re curious about what’s new in RSpec 3, check back in a few days – I’ll be posting full list of notable changes in RSpec 3 soon.
Thanks to all the contributors who helped make this release happen!
Release Notes
rspec-core 2.99.0.rc1
Enhancements:
- Add
--deprecation-outCLI option which directs deprecation warnings to the named file. (Myron Marston) - Backport support for
skipin metadata to skip execution of an example. (Xavier Shay, #1472) - Add
Pathnamesupport for setting all output streams. (Aaron Kromer) - Add
test_unitandminitestexpectation frameworks. (Aaron Kromer)
Deprecations:
- Deprecate
RSpec::Core::Pending::PendingDeclaredInExample, useSkipDeclaredInExampleinstead. (Xavier Shay) - Issue a deprecation when
described_classis accessed from within a nesteddescribe <SomeClass>example group, sincedescribed_classwill return the innermost described class in RSpec 3 rather than the outermost described class, as it behaved in RSpec 2. (Myron Marston) - Deprecate
RSpec::Core::FilterManager::DEFAULT_EXCLUSIONS,RSpec::Core::FilterManager::STANDALONE_FILTERSand use of#empty_without_conditional_filters?on those filters. (Sergey Pchelincev) - Deprecate
RSpec::Core::Example#optionsin favor ofRSpec::Core::Example#metadata. (Myron Marston) - Issue warning when passing a symbol or hash to
describeorcontextas the first argument. In RSpec 2.x this would be treated as metadata but in RSpec 3 it’ll be treated as the described object. To continue having it treated as metadata, pass a description before the symbol or hash. (Myron Marston) - Deprecate
RSpec::Core::BaseTextFormatter::VT100_COLORSandRSpec::Core::BaseTextFormatter::VT100_COLOR_CODESin favour ofRSpec::Core::BaseTextFormatter::ConsoleCodes::VT100_CODESandRSpec::Core::BaseTextFormatter::ConsoleCodes::VT100_CODE_VALUES. (Jon Rowe) - Deprecate
RSpec::Core::ExampleGroup.display_namein favor ofRSpec::Core::ExampleGroup.description. (Myron Marston) - Deprecate
RSpec::Core::ExampleGroup.describesin favor ofRSpec::Core::ExampleGroup.described_class. (Myron Marston) - Deprecate
RSpec::Core::ExampleGroup.alias_example_toin favor ofRSpec::Core::Configuration#alias_example_to. (Myron Marston) - Deprecate
RSpec::Core::ExampleGroup.alias_it_behaves_like_toin favor ofRSpec::Core::Configuration#alias_it_behaves_like_to. (Myron Marston) - Deprecate
RSpec::Core::ExampleGroup.focusedin favor ofRSpec::Core::ExampleGroup.focus. (Myron Marston) - Add deprecation warning for
config.filter_run :focusedsince example aliasesfitandfocuswill no longer include:focusedmetadata but will continue to include:focus. (Myron Marston) - Deprecate filtering by
:line_number(e.g.--line-numberfrom the CLI). Use location filtering instead. (Myron Marston) - Deprecate
--default_pathas an alternative to--default-path. (Jon Rowe) - Deprecate
RSpec::Core::Configuration#warningsin favor ofRSpec::Core::Configuration#warnings?. (Myron Marston) - Deprecate
share_examples_forin favor ofshared_examples_foror justshared_examples. (Myron Marston) - Deprecate
RSpec::Core::CommandLinein favor ofRSpec::Core::Runner. (Myron Marston) - Deprecate
#color_enabled,#color_enabled=and#color?in favour of#color,#color=and#color_enabled? output. (Jon Rowe) - Deprecate
#filename_patternin favour of#pattern. (Jon Rowe) - Deprecate
#backtrace_cleanerin favour of#backtrace_formatter. (Jon Rowe) - Deprecate mutating
RSpec::Configuration#formatters. (Jon Rowe) - Deprecate
stdlibas an available expectation framework in favour oftest_unitandminitest. (Aaron Kromer)
Bug Fixes:
- Issue a warning when you set
config.deprecation_streamtoo late for it to take effect because the reporter has already been setup. (Myron Marston) skipwith a block should not execute the block. (Xavier Shay)
rspec-core 3.0.0.rc1
Breaking Changes for 3.0.0:
- Change
described_classso that in a nested group likedescribe MyClass, it returnsMyClassrather than the outer group’s described class. (Myron Marston) - Refactor filter manager so that it no longer subclasses Hash and has a tighter, more domain-specific interface. (Sergey Pchelincev)
- Remove legacy colours definitions from
BaseTextFormatter. (Jon Rowe) - Remove console color definitions from
BaseTextFormatter. (Jon Rowe) - Restructure example group metadata so that the computed keys are
exposed directly off of the metadata hash rather than being on
a nested
:example_groupsubhash. In addition, the parent example group metadata is now available as[:parent_example_group]rather than[:example_group][:example_group]. Deprecated access via the old key structure is still provided. (Myron Marston) - Remove
:describesmetadata key. It duplicates:described_classfor no good reason. Deprecated access via:describesis still provided. (Myron Marston) - Rename
:example_group_blockmetadata key to:block. (Myron Marston) - Remove deprecated
RSpec::Core::Example#options. (Myron Marston) - Move
BaseTextFormatter#colorize_summarytoSummaryNotification#colorize_with(Jon Rowe). describe some_hashtreatedsome_hashas metadata in RSpec 2.x but will treat it as the described object in RSpec 3.0. Metadata must always come after the description args. (Myron Marston)- Remove deprecated
display_namealias ofExampleGroup.description. (Myron Marston) - Remove deprecated
describesalias ofExampleGroup.described_class. (Myron Marston) - Remove deprecated
RSpec::Core::ExampleGroup.alias_it_behaves_like_to. UseRSpec::Core::Configuration#alias_it_behaves_like_toinstead. (Myron Marston) - Remove deprecated
RSpec::Core::ExampleGroup.alias_example_to. UseRSpec::Core::Configuration#alias_example_toinstead. (Myron Marston) - Removed
focusedexample alias and change example/group aliasesfit,focus,fcontextandfdescribeto no longer include:focused => truemetadata. They only contain:focus => truemetadata now. This means that you will need to filter them withfilter_run :focus, notfilter_run :focused. (Myron Marston) - Remove
--line-numberfiltering. It’s semantically dubious since it’s a global filter (potentially applied to multiple files) but there’s no meaningful connection between the same line number in multiple files. Instead use therspec path/to/spec.rb:23:46form, which is terser and makes more sense as it is scoped to a file. (Myron Marston) - Remove
--default_pathas an alias for--default-path. (Jon Rowe) - Remove deprecated
share_examples_for. There’s stillshared_examplesandshared_examples_for. (Myron Marston) - Rename
RSpec::Core::Configuration#warningstoRSpec::Core::Configuration#warnings?since it’s a boolean flag. (Myron Marston) - RSpec’s global state is no longer reset after a spec run. This gives more flexibility to alternate runners to decide when and if they want the state reset. Alternate runners are now responsible for calling this (or doing a similar reset) if they are going to run the spec suite multiple times in the same process. (Sam Phippen)
- Merge
RSpec::Core::CommandLine(never formally declared public) intoRSpec::Core::Runner. (Myron Marston) - Remove
color_enabledas an alias ofcolor. (Jon Rowe) - Remove
backtrace_cleaneras an alias ofbacktrace_formatter. (Jon Rowe) - Remove
filename_patternas an alias ofpattern. (Jon Rowe) - Extract support for legacy formatters to
rspec-legacy_formatters. (Jon Rowe) RSpec::Configuration#formattersnow returns a dup to prevent mutation. (Jon Rowe)- Replace
stdlibas an available expectation framework withtest_unitandminitest. (Aaron Kromer) - Remove backtrace formatting helpers from
BaseTextFormatter. (Jon Rowe) - Extract profiler support to
ProfileFormatterandProfileNotification. Formatters should implementdump_profileif they wish to respond to--profile. (Jon Rowe) - Extract remaining formatter state to reporter and notifications. Introduce
ExamplesNotificationto share information about examples that was previously held inBaseFormatter. (Jon Rowe)
Enhancements:
- Add
config.default_formatterattribute, which can be used to set a formatter which will only be used if no other formatter is set (e.g. via--formatter). (Myron Marston) - Support legacy colour definitions in
LegacyFormatterAdaptor. (Jon Rowe) - Migrate
execution_result(exposed by metadata) from a hash to a first-class object with appropriate attributes.statusis now stored and returned as a symbol rather than a string. It retains deprecated hash behavior for backwards compatibility. (Myron Marston) - Provide console code helper for formatters. (Jon Rowe)
- Use raw ruby hashes for the metadata hashes rather than a subclass of a hash. Computed metadata entries are now computed in advance rather than being done lazily on first access. (Myron Marston)
- Add
:blockmetadata entry to the example metadata, bringing parity with:blockin the example group metadata. (Myron Marston) - Add
fspecifyandfexampleas aliases ofspecifyandexamplewith:focus => truemetadata for parity withfit. (Myron Marston) - Add legacy support for
colorize_summary. (Jon Rowe) - Restructure runner so it can be more easily customized in a subclass for an alternate runner. (Ben Hoskings)
- Document
RSpec::Core::ConfigurationOptionsas an officially supported public API. (Myron Marston) - Add
--deprecation-outCLI option which directs deprecation warnings to the named file. (Myron Marston) - Minitest 5 compatability for
expect_with :stdlib(now available asexpect_with :minitest). (Xavier Shay) - Reporter now notifies formatters of the load time of RSpec and your
specs via
StartNotificationandSummaryNotification. (Jon Rowe) - Add
disable_monkey_patching!config option that disables all monkey patching from whatever pieces of RSpec you use. (Alexey Fedorov) - Add
Pathnamesupport for setting all output streams. (Aaron Kromer) - Add
config.define_derived_metadata, which can be used to apply additional metadata to all groups or examples that match a given filter. (Myron Marston) - Provide formatted and colorized backtraces via
FailedExampleNotificationand sendPendingExampleFixedNotificationswhen the error is due to a passing spec you expect to fail. (Jon Rowe) - Add
dump_profileto formatter API to allow formatters to implement support for--profile. (Jon Rowe) - Allow colourising text via
ConsoleCodeswith RSpec ‘states’ (e.g.:success,:failure) rather than direct colour codes. (Jon Rowe) - Expose
fully_formattedmethods off the formatter notification objects that make it easy for a custom formatter to produce formatted output like rspec-core’s. (Myron Marston)
Bug Fixes:
- Fix
spec_helper.rbfile generated byrspec --initso that the recommended settings correctly use the documentation formatter when running one file. (Myron Marston) - Fix ordering problem where descriptions were generated after tearing down mocks, which resulted in unexpected exceptions. (Bradley Schaefer, Aaron Kromer, Andrey Savchenko)
- Allow a symbol to be used as an implicit subject (e.g.
describe :foo). (Myron Marston) - Prevent creating an isolated context (i.e. using
RSpec.describe) when already inside a context. There is no reason to do this, and it could potentially cause unexpected bugs. (Xavier Shay) - Fix shared example group scoping so that when two shared example groups share the same name at different levels of nested contexts, the one in the nearest context is used. (Myron Marston)
- Fix
--warningsoption so that it enables warnings immediately so that it applies to files loaded by--require. (Myron Marston) - Issue a warning when you set
config.deprecation_streamtoo late for it to take effect because the reporter has already been setup. (Myron Marston) - Add the full
RSpec::Core::Exampleinterface to the argument yielded toaroundhooks. (Myron Marston) - Line number always takes precendence when running specs with filters. (Xavier Shay)
- Ensure :if and :unless metadata filters are treated as a special case and are always in-effect. (Bradley Schaefer)
- Ensure the currently running installation of RSpec is used when
the rake task shells out to
rspec, even if a newer version is also installed. (Postmodern) - Using a legacy formatter as default no longer causes an infinite loop. (Xavier Shay)
rspec-expectations 2.99.0.rc1
Deprecations:
- Deprecate
matcher_execution_contextattribute on DSL-defined custom matchers. (Myron Marston) - Deprecate
RSpec::Matchers::Pretty#_pretty_print. (Myron Marston) - Deprecate
RSpec::Matchers::Pretty#expected_to_sentence. (Myron Marston) - Deprecate
RSpec::Matchers::Configurationin favor ofRSpec::Expectations::Configuration. (Myron Marston) - Deprecate
be_xyzpredicate matcher on an object that doesn’t respond toxyz?orxyzs?. (Daniel Fone) - Deprecate
have_xyzmatcher on an object that doesn’t respond tohas_xyz?. (Daniel Fone) - Deprecate
have_xyzmatcher on an object that has a private methodhas_xyz?. (Jon Rowe) - Issue a deprecation warning when a block expectation expression is
used with a matcher that doesn’t explicitly support block expectations
via
supports_block_expectations?. (Myron Marston) - Deprecate
require 'rspec-expectations'. Userequire 'rspec/expectations'instead. (Myron Marston)
rspec-expectations 3.0.0.rc1
Breaking Changes for 3.0.0:
- Remove
matcher_execution_contextattribute from DSL-defined custom matchers. (Myron Marston) - Remove
RSpec::Matchers::Pretty#_pretty_print. (Myron Marston) - Remove
RSpec::Matchers::Pretty#expected_to_sentence. (Myron Marston) - Rename
RSpec::Matchers::Configurationconstant toRSpec::Expectations::Configuration. (Myron Marston) - Prevent
have_xyzpredicate matchers using private methods. (Adrian Gonzalez) - Block matchers must now implement
supports_block_expectations?. (Myron Marston) - Stop supporting
require 'rspec-expectations'. Userequire 'rspec/expectations'instead. (Myron Marston)
Bug Fixes:
- Fix
NoMethodErrortriggered by beta2 whenYARDwas loaded in the test environment. (Myron Marston) - Fix
be_xyzmatcher to accept ado...endblock. (Myron Marston) - Fix composable matcher failure message generation logic
so that it does not blow up when given
$stdoutor$stderr. (Myron Marston) - Fix
changematcher to work properly withIOobjects. (Myron Marston) - Fix
existmatcher so that it can be used in composed matcher expressions involving objects that do not implementexist?orexists?. (Daniel Fone) - Fix composable matcher match logic so that it clones matchers
before using them in order to work properly with matchers
that use internal memoization based on a given
actualvalue. (Myron Marston) - Fix
be_xyzandhas_xyzpredicate matchers so that they can be used in composed matcher expressions involving objects that do not implement the predicate method. (Daniel Fone)
Enhancements:
- Document the remaining public APIs. rspec-expectations now has 100% of the public API documented and will remain that way (as new undocumented methods will fail the build). (Myron Marston)
- Improve the formatting of BigDecimal objects in
eqmatcher failure messages. (Daniel Fone) - Improve the failure message for
be_xyzpredicate matchers so that it includes theinspectoutput of the receiver. (Erik Michaels-Ober, Sam Phippen) - Add
allmatcher, to allow you to specify that a given matcher matches all elements in a collection:expect([1, 3, 5]).to all( be_odd ). (Adam Farhi) - Add boolean aliases (
&/|) for compound operators (and/or). (Adam Farhi) - Give users a clear error when they wrongly use a value matcher
in a block expectation expression (e.g.
expect { 3 }.to eq(3)) or vice versa. (Myron Marston)
rspec-mocks 2.99.0.rc1
Deprecations:
- Deprecate
RSpec::Mocks::TestDouble.extend_onto. (Myron Marston) - Deprecate
RSpec::Mocks::ConstantStubber. (Jon Rowe) - Deprecate
Marshal.dumpmonkey-patch without opt-in. (Xavier Shay)
rspec-mocks 3.0.0.rc1
Breaking Changes for 3.0.0:
- Remove
RSpec::Mocks::TestDouble.extend_onto. (Myron Marston) - Remove
RSpec::Mocks::ConstantStubber. (Jon Rowe) - Make monkey-patch of Marshal to support dumping of stubbed objects opt-in. (Xavier Shay)
Enhancements:
- Instead of crashing when cleaning up stub methods on a frozen object, it now issues a warning explaining that it’s impossible to clean up the stubs. (Justin Coyne and Sam Phippen)
- Add meaningful descriptions to
anything,duck_typeandinstance_ofargument matchers. (Jon Rowe)
Bug Fixes:
- Fix regression introduced in 3.0.0.beta2 that caused
double.as_null_object.to_strto return the double rather than a string. (Myron Marston) - Fix bug in
expect(dbl).to receive_message_chain(:foo, :bar)where it was not setting an expectation for the last message in the chain. (Jonathan del Strother) - Allow verifying partial doubles to have private methods stubbed. (Xavier Shay)
- Fix bug with allowing/expecting messages on Class objects which have had their singleton class prepended to. (Jon Rowe)
- Fix an issue with 1.8.7 not running implementation blocks on partial doubles. (MaurĂcio Linhares)
- Prevent
StackLevelTooDeeperrors when stubbing anany_instancemethod that’s accessed ininspectby providing our own inspect output. (Jon Rowe) - Fix bug in
any_instancelogic that did not allow you to mock or stub private methods ifverify_partial_doubleswas configured. (Oren Dobzinski) - Include useful error message when trying to observe an unimplemented method on an any instance. (Xavier Shay)
- Fix
and_call_originalto work properly when multiple classes in an inheritance hierarchy have been stubbed with the same method. (Myron Marston) - Fix
any_instanceso that it updates existing instances that have already been stubbed. (Myron Marston) - Fix verified doubles so that their class name is included in failure messages. (Myron Marston)
- Fix
expect_any_instance_ofso that when the message is received on an individual instance that has been directly stubbed, it still satisfies the expectation. (Sam Phippen, Myron Marston) - Explicitly disallow using
any_instanceto mock or stub a method that is defined on a module prepended onto the class. This triggeredSystemStackErrorbefore and is very hard to support so we are not supporting it at this time. (Myron Marston)
rspec-rails 2.99.0.rc1
Deprecations
- Deprecates
stub_modelandmock_modelin favor of therspec-activemodel-mocksgem. (Thomas Holmes) - Issue a deprecation to instruct users to configure
config.infer_spec_type_from_file_location!during the upgrade process since spec type inference is opt-in in 3.0. (Jon Rowe) - Issue a deprecation when
described_classis accessed in a controller example group that has used thecontroller { }macro to generate an anonymous controller class, since in 2.x,described_classwould return that generated class but in 3.0 it will continue returning the class passed todescribe. (Myron Marston)
rspec-rails 3.0.0.rc1
Breaking Changes for 3.0.0:
- Extracts the
mock_modelandstub_modelmethods to therspec-activemodel-mocksgem. (Thomas Holmes) - Spec types are no longer inferred by location, they instead need to be
explicitly tagged. The old behaviour is enabled by
config.infer_spec_type_from_file_location!, which is still supplied in the default generatedspec_helper.rb. (Xavier Shay, Myron Marston) controllermacro in controller specs no longer mutates:described_classmetadata. It still overrides the subject and sets the controller, though. (Myron Marston)- Stop depending on or requiring
rspec-collection_matchers. Users who want those matchers should add the gem to their Gemfile and require it themselves. (Myron Marston) - Removes runtime dependency on
ActiveModel. (Rodrigo Rosenfeld Rosas)
Enhancements:
- Supports Rails 4.x reference attribute ids in generated scaffold for view specs. (Giovanni Cappellotto)
- Add
have_http_statusmatcher. (Aaron Kromer) - Add spec type metadata to generator templates. (Aaron Kromer)
Bug Fixes:
- Fix an inconsistency in the generated scaffold specs for a controller. (Andy Waite)
- Ensure
config.before(:all, :type => <type>)hooks run before groups of the given type, even when the type is inferred by the file location. (Jon Rowe, Myron Marston) - Switch to parsing params with
Rack::Utils::parse_nested_queryto match Rails. (Tim Watson) - Fix incorrect namespacing of anonymous controller routes. (Aaron Kromer)