RSpec runner and formatters
Enhancements:
is_expected
for one-liners that read well with the
expect
-based syntax. is_expected
is simply defined as
expect(subject)
and can be used in an expression like:
it { is_expected.to read_well }
. (Myron Marston)skip
from RSpec 3, which acts like pending
did in RSpec 2
when not given a block, since the behavior of pending
is changing in
RSpec 3. (Xavier Shay)Deprecations:
mock_with
config options. RSpec 3 will only support
the exact symbols :rspec
, :mocha
, :flexmock
, :rr
or :nothing
(or any module that implements the adapter interface). RSpec 2 did
fuzzy matching but this will not be supported going forward.
(Myron Marston)show_failures_in_pending_blocks
config option. To achieve
the same behavior as the option enabled, you can use a custom
formatter instead. (Xavier Shay)pending
is changing in RSpec 3 -- rather than skipping the example (as it did
in 2.x when no block was provided), it will run the example and mark
it as failed if no exception is raised. Use skip
instead to preserve
the old behavior. (Xavier Shay)RSpec::Core::Reporter#abort
in favor of
RSpec::Core::Reporter#finish
. (Jon Rowe)Bug Fixes:
path
) in end-of-run summary
when raise_errors_for_deprecations!
is configured. (Myron Marston)Breaking Changes for 3.0.0:
mock_with
option more strict. Strings are no longer supported
(e.g. mock_with "mocha"
) -- use a symbol instead. Also, unrecognized
values will now result in an error rather than falling back to the
null mocking adapter. If you want to use the null mocking adapter,
use mock_with :nothing
(as has been documented for a long time).
(Myron Marston):if
and :unless
filters. (Ashish Dixit)RSpec::Core::Formatters.register(formatter_class, *notifications)
where notifications
is the list of events the formatter wishes to
be notified about. Notifications are handled by methods matching the
names on formatters. This allows us to add or remove notifications
without breaking existing formatters. (Jon Rowe):alias
option for
RSpec.configuration.add_setting
. (Myron Marston)RSpec.configuration.requires = [...]
.
(Myron Marston)--formatter
CLI option. (Myron Marston)--configure
CLI option. (Myron Marston)RSpec::Core::RakeTask#spec_opts=
.
(Myron Marston)pending
block or :pending
metadata now executes
the example and cause a failure if it passes, otherwise it will be pending if
it fails. The old "never run" behaviour is still used for xexample
, xit
,
and xspecify
, or via a new skip
method or :skip
metadata option.
(Xavier Shay)pending
inside an example, the remainder of the example will
now be run. If it passes a failure is raised, otherwise the example is marked
pending. The old "never run" behaviour is provided a by a new skip
method.
(Xavier Shay)skip
or pending
without a block. (Xavier Shay)before(:all)
hooks. Use skip
instead. (Xavier Shay)show_failures_in_pending_blocks
configuration option. (Xavier Shay)Enhancements:
is_expected
for one-liners that read well with the
expect
-based syntax. is_expected
is simply defined as
expect(subject)
and can be used in an expression like:
it { is_expected.to read_well }
. (Myron Marston)rspec --init
. (Myron Marston)config.alias_example_group_to
, which can be used to define a
new method that defines an example group with the provided metadata.
(Michi Huber)xdescribe
and xcontext
as shortcuts to make an example group
pending. (Myron Marston)fdescribe
and fcontext
as shortcuts to focus an example group.
(Myron Marston)#at_exit
by default. require 'rspec/autorun'
is only needed when running specs via ruby
, as it always has been.
Running specs via rake
or rspec
are both unaffected. (Ben Hoskings)expose_dsl_globally
config option, defaulting to true. When disabled
it will remove the monkey patches rspec-core adds to main
and Module
(e.g. describe
, shared_examples_for
, etc). (Jon Rowe)describe
,
shared_examples_for
, etc) on the RSpec
constant. Intended for use
when expose_dsl_globally
is set to false
. (Jon Rowe)context
) on the RSpec
constant. If expose_dsl_globally
is set to
true
, also expose them on main
and Module
. Historically, only describe
was exposed. (Jon Rowe, Michi Huber)Bug Fixes:
path
) in end-of-run summary
when raise_errors_for_deprecations!
is configured. (Myron Marston)failure_exit_code
is used by the rake
task when there is a failure. (Jon Rowe)line_number
or default_path
. (Matijs van Zuijlen)Breaking Changes for 3.0.0:
RSpec::Core::ExampleGroup#example
and
RSpec::Core::ExampleGroup#running_example
methods. If you need
access to the example (e.g. to get its metadata), use a block arg
instead. (David Chelimsky)TextMateFormatter
, it has been moved to rspec-tmbundle
.
(Aaron Kromer)Spec
and Rspec
constants (rather than RSpec
).Spec::Runner.configure
rather than RSpec.configure
.Rake::SpecTask
rather than RSpec::Core::RakeTask
.share_as
. (Myron Marston)--debug
option (and corresponding option on
RSpec::Core::Configuration
). Instead, use -r<debugger gem name>
to
load whichever debugger gem you wish to use (e.g. ruby-debug
,
debugger
, or pry
). (Myron Marston)let
or subject
declaration is
accessed in a before(:all)
or after(:all)
hook. (Myron Marston)its
support to a separate gem. (Peter Alfvin)RSpec::Core::Configuration#output
and
RSpec::Core::Configuration#out
aliases of
RSpec::Core::Configuration#output_stream
. (Myron Marston)Enhancements
failure_color
.
(Matthew Boedicker)--no-fail-fast
command line option. (Gonzalo Rodríguez-Baltanás Díaz)--profile
information. (Alex / @MasterLambaster)treat_symbols_as_metadata_keys_with_true_values
but
now this behavior is always enabled. (Myron Marston)--dry-run
option, which prints the formatter output
of your suite without running any examples or hooks.
(Thomas Stratmann, Myron Marston)spec_helper.rb
file that is generated by RSpec. (Parker Selbert)Deprecations
treat_symbols_as_metadata_keys_with_true_values
is deprecated and no
longer has an affect now that the behavior it enabled is always
enabled. (Myron Marston)Enhancements
it
, before(:each)
, after(:each)
, let
and subject
)
now yield the example as a block argument. (David Chelimsky)include_examples
and it's aliases. (David Chelimsky)expose_current_running_example_as
config option for
use during the upgrade process when external gems use the
deprecated RSpec::Core::ExampleGroup#example
and
RSpec::Core::ExampleGroup#running_example
methods. (Myron Marston)config.raise_errors_for_deprecations!
option, which turns
deprecations warnings into errors to surface the full backtrace
of the call site. (Myron Marston)Deprecations
RSpec::Core::ExampleGroup#example
and
RSpec::Core::ExampleGroup#running_example
methods. If you need
access to the example (e.g. to get its metadata), use a block argument
instead. (David Chelimsky)autotest/rspec2
in favour of rspec-autotest
. (Jon Rowe)-rruby-debug
(for the ruby-debug gem) or -rdebugger
(for the
debugger gem) instead. (Myron Marston)RSpec.configuration.treat_symbols_as_metadata_keys_with_true_values = false
.
RSpec 3 will not support having this option set to false
. (Myron Marston)let
or subject
declaration in
a after(:all)
hook. (Myron Marston, Jon Rowe)its
usage in favor of rspec-its
gem due to planned
removal in RSpec 3. (Peter Alfvin)RSpec::Core::PendingExampleFixedError
in favor of
RSpec::Core::Pending::PendingExampleFixedError
. (Myron Marston)RSpec::Core::Configuration#out
and
RSpec::Core::Configuration#output
in favor of
RSpec::Core::Configuration#output_stream
. (Myron Marston)register_ordering(:global)
instead of these:
RSpec::Core::Configuration#order_examples
RSpec::Core::Configuration#order_groups
RSpec::Core::Configuration#order_groups_and_examples
RSpec::Core::Configuration#order
RSpec::Core::Configuration#randomize?
--order default
is deprecated in favor of --order defined
(Myron Marston)Bug fixes:
example.execution_result[:exception].pending_fixed?
(which
was removed in 2.14.6 to fix an issue with frozen error objects)
or RSpec::Core::PendingExampleFixedError
(which was renamed
to RSpec::Core::Pending::PendingExampleFixedError
in 2.8.
This fix makes a constant alias for the old error name.
(Myron Marston)Bug fixes:
NoMethodError
that was being raised when there were no shared
examples or contexts declared and RSpec.world.reset
is invoked.
(thepoho, Jon Rowe, Myron Marston)shared_examples
are declared at top level in a module
scope.
(Jon Rowe)dump_profile
isn't defined (Alex / @MasterLambaster, Jon Rowe)Bug fixes
-r
option)
are loaded before spec files are loaded. This allows the spec files
to programatically change the file pattern (Jon Rowe).RSpec::Mocks
and RSpec::Expectations
when referenced if
they are not already loaded (RSpec::Matches
has been autoloaded
for a while). In the rspec
gem, we changed it recently to stop
loading rspec/mocks
and rspec/expectations
by default, as some
users reported problems where they were intending to use mocha,
not rspec-mocks, but rspec-mocks was loaded and causing a conflict.
rspec-core loads mocks and expectations at the appropriate time, so
it seemed like a safe change -- but caused a problem for some authors
of libraries that integrate with RSpec. This fixes that problem.
(Myron Marston)rspec --profile path/to/spec.rb
:
the path/to/spec.rb
arg was being wrongly treated as the profile
integer arg, which got cast 0
using to_i
, causing no profiled
examples to be printed. (Jon Rowe)