rspec-expectations/Changelog.md
Breaking Changes:
should and should_not syntax (including one-liners). (Phil Pirozhkov, rspec/rspec-expectations#1245)strict_predicate_matchers on by default. (Phil Pirozhkov, rspec/rspec-expectations#1277)include_chain_clauses_in_custom_matcher_descriptions option
and make it the default. (Phil Pirozhkov, rspec/rspec-expectations#1279)match_regex matcher. (Phil Pirozhkov, rspec/rspec-expectations#1288)StartAndEndWith matcher base class. (Phil Pirozhkov, rspec/rspec-expectations#1288)ArgumentError when a nil is passed as the first argument to raise_error.
(Phil Pirozhkov, rspec/rspec-expectations#1389)RSpec::Expectations::Config#warn_about_potential_false_positives.
(Anthony Clark, Phil Pirozhkov, rspec/rspec#260)Enhancements:
output(...).to_stdout et al)
by adding as_tty and as_not_tty to change the tty? flags. (Sergio Gil Pérez de la Manga, rspec/rspec-expectations#1459)change matcher.
(Qingyu Chai, rspec/rspec#177)Bug Fixes:
Bug Fixes:
match from trying to compare strings and arrays using Array#match. (Joseph Haig, rspec/rspec#183)Bug Fixes:
include matcher without a count constraint.
(Jon Rowe, rspec/rspec-expectations#1485)Bug Fixes:
RSpec.warning for an expectation warning rather than Kernel.warn. (Jon Rowe, rspec/rspec-expectations#1472)include matcher. (Eric Mueller, rspec/rspec-expectations#1479)Bug Fixes:
raise_error matcher
with a RegExp instance. (Eric Mueller, rspec/rspec-expectations#1456)Enhancements:
eq and eql matchers to better highlight difference in string encoding.
(Alan Foster, rspec/rspec-expectations#1425)Bug Fixes:
actual and reassigned @actual in compound
expectations failure messages. (Phil Pirozhkov, rspec/rspec-expectations#1440)Bug Fixes:
include matcher when fuzzy matching on keys with a hash-like actual which
has a non standard key? method which may raise.
(Jon Rowe, rspec/rspec-expectations#1416)Bug Fixes:
exist matcher with Dir.
(Steve Dierker, rspec/rspec-expectations#1398)Bug Fixes:
Enhancements:
an_array_matching alias for match_array to improve readability as an argument
matcher. (Mark Schneider, rspec/rspec-expectations#1361)Bug Fixes:
contain_exactly matcher to be reused by resetting its
internals on matches? (@bclayman-sq, rspec/rspec-expectations#1326)FileTest no longer produces a deprecation warning.
(Ryo Nakamura, rspec/rspec-expectations#1383)Enhancements:
true from aggregate_failures when no exception occurs. (Jon Rowe, rspec/rspec-expectations#1225)Deprecations:
Bug Fixes:
expect(array).to include(hash).times, previously this would fail due to
matching the entire array as a single hash, rather than a member of the hash.
(Slava Kardakov, rspec/rspec-expectations#1322)raise_error matches works with the error_highlight option from Ruby 3.1.
(Peter Goldstein, rspec/rspec-expectations#1339)Bug Fixes:
Enhancements:
include matcher to be chained with once, at_least, etc. for simple cases.
(Marc-André Lafortune, rspec/rspec-expectations#1168)nil is passed to raise_error. (Phil Pirozhkov, rspec/rspec-expectations#1143)include matcher's composability. (Phil Pirozhkov, rspec/rspec-expectations#1155)aggregate_failures now shows the backtrace line for each failure. (Fabricio Bedin, rspec/rspec-expectations#1163)yield_control modifiers like at_least, at_most.
(Jon Rowe, rspec/rspec-expectations#1169)have_<n> matchers now have output consistent with other dynamic matchers.
(Marc-André Lafortune, rspec/rspec-expectations#1195)strict_predicate_matchers allows predicate matcher to be strict
(i.e. match for true or false) instead of the default (match truthy vs false or nil).
(Marc-André Lafortune, rspec/rspec-expectations#1196)Bug Fixes:
be_ and have_ matchers and arguments implementing to_hash
were they would act like keywords and be cast to a hash. (Jon Rowe, rspec/rspec-expectations#1222)Bug Fixes:
be_within matcher allowing
more complicated oobjects to be compared providing they provide abs and other
comparison methods. (Kelly Stannard, rspec/rspec-expectations#1182)be_within matcher. (Jon Rowe, rspec/rspec-expectations#1185)be_ and have_ matchers on 2.7.x
(Jon Rowe, rspec/rspec-expectations#1187)EnglishPhrasing#list). (Robert Eshleman, rspec/rspec-expectations#1193)be <operator> comparison, e.g.
expect(1).not_to be < 'a' will now correctly fail rather than pass. (Jon Rowe, rspec/rspec-expectations#1208)Bug Fixes:
ArgumentError when invalid arguments are given to yield_control
modifiers such as at_least et al. (Marc-André Lafortune, rspec/rspec-expectations#1167)Bug Fixes:
respond_to(...).with(n).arguments and ignore
the warning when using with have_attributes(...). (Jon Rowe, rspec/rspec-expectations#1164)Enhancements:
respond_to matcher now uses the signature from initialize to validate checks
for new (unless new is non standard). (Jon Rowe, rspec/rspec-expectations#1072)is expected to rather than should in
line with our preferred DSL. (Pete Johns, rspec/rspec-expectations#1080, rspec/rspec-corerspec/rspec-expectations#2572)match_when_negated blocks. (Jon Rowe, rspec/rspec-expectations#1130)Bug Fixes:
Bug Fixes:
Bug Fixes:
be_an_instance_of and be_kind_of matchers. (Nazar Matus, rspec/rspec-expectations#1112)Bug Fixes:
all matchers from leaking into their siblings leading to duplicate
failures. (Jamie English, rspec/rspec-expectations#1086)ArgumentError rather than a NoMethodError when be_an_instance_of and
be_kind_of matchers encounter objects not supporting those methods.
(Taichi Ishitani, rspec/rspec-expectations#1107)Bug Fixes:
include matcher to rely on a respond_to?(:include?) check rather than a direct
Hash comparison before calling to_hash to convert to a hash. (Jordan Owens, rspec/rspec-expectations#1073)IndexError), and
replace that error with a proper informative message. (Jon Rowe, rspec/rspec-expectations#1076)Bug Fixes:
include matcher so stopped
expect(hash.with_indifferent_access).to include(:symbol_key)
from working. (Eito Katagiri, rspec/rspec-expectations#1069)Enhancements:
change(receiver, :message) by including the
receiver as SomeClass#some_message. (Tomohiro Hashidate, rspec/rspec-expectations#1005)change matcher so that it can correctly detect changes in
deeply nested mutable objects (such as arrays-of-hashes-of-arrays).
The improved logic uses the before/after hash value to see if the
object has been mutated, rather than shallow duping the object.
(Myron Marston, rspec/rspec-expectations#1034)include matcher so that pseudo-hash objects (e.g. objects
that decorate a hash using a SimpleDelegator or similar) are treated
as a hash, as long as they implement to_hash. (Pablo Brasero, rspec/rspec-expectations#1012)max_formatted_output_length= to configuration, allowing changing
the length at which we truncate large output strings.
(Sam Phippen rspec/rspec-expectations#951, Benoit Tigeot rspec/rspec-expectations#1056)expect. (@nicktime, rspec/rspec-expectations#1066)Enhancements:
--enable-frozen-string-literal option
on Ruby 2.3+. (Pat Allan, rspec/rspec-expectations#997)Enhancements:
alias_matcher or define_negated_matcher from within an example
group. (Markus Reiter, rspec/rspec-expectations#974)change matcher with block and satisfy matcher
by including the block snippet instead of just describing it as result or
block when Ripper is available. (Yuji Nakayama, rspec/rspec-expectations#987)Bug Fixes:
yield_with_args and yield_successive_args matchers so that
they compare expected to actual args at the time the args are yielded
instead of at the end, in case the method that is yielding mutates the
arguments after yielding. (Alyssa Ross, rspec/rspec-expectations#965)Bug Fixes:
File no longer produces a deprecation warning.
(Jon Rowe, rspec/rspec-expectations#954)Bug Fixes:
contain_exactly to work correctly with ranges. (Myron Marston, rspec/rspec-expectations#940)change to work correctly with sets. (Marcin Gajewski, rspec/rspec-expectations#939)Enhancements:
respond_to matcher. (Rob Smith, rspec/rspec-expectations#915).Bug Fixes:
include matcher so that it provides a valid diff for hashes. (Yuji Nakayama, rspec/rspec-expectations#916)Enhancements:
rspec/expectations/minitest_integration work on Minitest::Spec
5.6+. (Myron Marston, rspec/rspec-expectations#904)having_attributes for have_attributes matcher.
(Yuji Nakayama, rspec/rspec-expectations#905)change matcher error message when block is mis-used.
(Alex Altair, rspec/rspec-expectations#908)Enhancements:
RSpec::Configuration#on_potential_false_positives = :raise. (Jon Rowe, rspec/rspec-expectations#900)notify_expectation_failures: true option for the match method to
allow expectation failures to be raised as normal instead of being
converted into a false return value for matches?. (Jon Rowe, rspec/rspec-expectations#892)Bug Fixes:
should deprecation check to work on BasicObjects. (James Coleman, rspec/rspec-expectations#898)Enhancements:
match_when_negated in custom matcher DSL support use of
expectations within the match logic. (Chris Arcand, rspec/rspec-expectations#789)Bug Fixes:
true as expected from passing negated expectations
(such as expect("foo").not_to eq "bar"), so they work
properly when used within a match or match_when_negated
block. (Chris Arcand, rspec/rspec-expectations#789)Enhancements:
RSpec::Matchers is included in a superclass after it has
already been included in a subclass on MRI 1.9, since that situation
can cause uses of super to trigger infinite recursion. (Myron Marston, rspec/rspec-expectations#816)NoMemoryError, SignalExcepetion, Interrupt and
SystemExit. It is dangerous to interfere with these. (Myron Marston, rspec/rspec-expectations#845)#with_captures to the match matcher which allows a user to specify expected
captures when matching a regex against a string. (Sam Phippen, rspec/rspec-expectations#848)Bug Fixes:
to_s -- that way for nil, "nil" is
printed rather than an empty string. (Myron Marston, rspec/rspec-expectations#841)#each includes the object itself. (Yuji Nakayama, rspec/rspec-expectations#857)Bug Fixes:
be >, be <, etc so that it fails rather than allowing an
argument error to be raised when compared against an object of the
wrong type. This allows it to be used in composed matcher expressions
against heterogeneous objects. (Dennis Günnewig, rspec/rspec-expectations#809)respond_to to work properly on target objects
that redefine the method method. (unmanbearpig, rspec/rspec-expectations#821)Enhancements:
RSpec::Matchers::EnglishPhrasing to make it easier to write
nice failure messages in custom matchers. (Jared Beck, rspec/rspec-expectations#736)RSpec::Matchers::FailMatchers, a mixin which provides
fail, fail_with and fail_including matchers for use in
specifying that an expectation fails for use by
extension/plugin authors. (Charlie Rudolph, rspec/rspec-expectations#729)tempfile (and its dependencies) unless
it is absolutely needed. (Myron Marston, rspec/rspec-expectations#735)be_true or be_false.
(Tim Wade, rspec/rspec-expectations#744)RSpec::Matchers#respond_to_missing? so that
RSpec::Matchers#respond_to? and RSpec::Matchers#method handle
dynamic predicate matchers. (Andrei Botalov, rspec/rspec-expectations#751)raise_error matcher that you may be subject to
false positives. (Jon Rowe, rspec/rspec-expectations#768)raise_error matcher in negative
expectations that may be subject to false positives. (Jon Rowe, rspec/rspec-expectations#775)include(a, b, c) so that if a and b
are included the failure message only mentions c. (Chris Arcand, rspec/rspec-expectations#780)satisfy matcher to take an optional description argument
that will be used in the description, failure_message and
failure_message_when_negated in place of the undescriptive
"sastify block". (Chris Arcand, rspec/rspec-expectations#783)aggregate_failures API that allows multiple independent
expectations to all fail and be listed in the failure output, rather
than the example aborting on the first failure. (Myron Marston, rspec/rspec-expectations#776)raise_error matcher so that it can accept a matcher as a single argument
that matches the message. (Time Wade, rspec/rspec-expectations#782)Bug Fixes:
contain_exactly / match_array work with strict test doubles
that have not defined <=>. (Myron Marston, rspec/rspec-expectations#758)include matcher so that it omits the diff when it would
confusingly highlight items that are actually included but are not
an exact match in a line-by-line diff. (Tim Wade, rspec/rspec-expectations#763)match matcher so that it does not blow up when matching a string
or regex against another matcher (rather than a string or regex).
(Myron Marston, rspec/rspec-expectations#772)Bug Fixes:
Ranges from being enumerated when generating matcher
descriptions. (Jon Rowe, rspec/rspec-expectations#755)raise_error
matcher. (Jon Rowe, rspec/rspec-expectations#755)Enhancements:
block_arg method to custom matcher API, which allows you to
access the block passed to a custom matcher, if there is one.
(Mike Dalton, rspec/rspec-expectations#645)yield_control matcher.
(Jon Rowe, rspec/rspec-expectations#650)chain in the matcher DSL which assigns values
for use elsewhere, for example chain :and_smaller_than, :small_value
creates an attr_reader for small_value (Tom Stuart, rspec/rspec-expectations#644)should syntax.
(Elia Schito, rspec/rspec-expectations#663)have_attributes matcher failure message.
(Jon Rowe, rspec/rspec-expectations#668)have_attributes matcher diffable.
(Jon Rowe, Alexey Fedorov, rspec/rspec-expectations#668)output(...).to_std(out|err)_from_any_process as alternatives
to output(...).to_std(out|err). The latter doesn't work when a sub
process writes to the named stream but is much faster.
(Alex Genco, rspec/rspec-expectations#700)and and or) so that diffs
are included in failures when one or more of their matchers
are diffable. (Alexey Fedorov, rspec/rspec-expectations#713)Bug Fixes:
private_methods from the be predicate matcher on
the target object if the object publicly responds to the predicate
method. This avoids a possible error that can occur if the object
raises errors from private_methods (which can happen with celluloid
objects). (@chapmajs, rspec/rspec-expectations#670)yield_control (with no modifier) default to
at_least(:once) rather than raising a confusing error
when multiple yields are encountered.
(Myron Marston, rspec/rspec-expectations#675)start_with and end_with to work properly when checking a
string against an array of strings. (Myron Marston, rspec/rspec-expectations#690)Bug Fixes:
define_negated_matcher so that matchers that support fluent
interfaces continue to be negated after you use the chained method.
(Myron Marston, rspec/rspec-expectations#656)define_negated_matcher so that the matchers fail with an
appropriate failure message. (Myron Marston, rspec/rspec-expectations#659)Bug Fixes:
all matcher in 3.1.0 that prevented it from
working on objects that are not Enumerable but do implement
each_with_index (such as an ActiveRecord proxy). (Jori Hardman, rspec/rspec-expectations#647)Enhancements:
have_attributes matcher, that passes if actual's attribute
values match the expected attributes hash:
Person = Struct.new(:name, :age)
person = Person.new("Bob", 32)
expect(person).to have_attributes(:name => "Bob", :age => 32).
(Adam Farhi, rspec/rspec-expectations#571)expect { ... }.to change { x }.to(3).and change { y }.to(4). (Myron
Marston, rspec/rspec-expectations#567)include_chain_clauses_in_custom_matcher_descriptions config
option is enabled. (Dan Oved, rspec/rspec-expectations#600)thrice modifier to yield_control matcher as a synonym for
exactly(3).times. (Dennis Taylor, rspec/rspec-expectations#615)RSpec::Matchers.define_negated_matcher, which defines a negated
version of the named matcher. (Adam Farhi, Myron Marston, rspec/rspec-expectations#618)contain_exactly/match_array.
(Jon Rowe, rspec/rspec-expectations#626).Bug Fixes:
LegacyMacherAdapter constant to LegacyMatcherAdapter
to fix typo. (Abdelkader Boudih, rspec/rspec-expectations#563)all matcher so that it fails properly (rather than raising a
NoMethodError) when matched against a non-enumerable. (Hao Su, rspec/rspec-expectations#622)Bug Fixes:
start_with and end_with so that they work properly with
structs. (Myron Marston, rspec/rspec-expectations#620)Bug Fixes:
BasicObject in 1.8.7. (Chris Griego, rspec/rspec-expectations#603)include matcher so that it fails gracefully when matched against
an object that does not respond to include?. (Myron Marston, rspec/rspec-expectations#607)Bug Fixes:
contain_exactly (AKA match_array) that caused it
to wrongly pass when the expected array was empty. (Myron Marston, rspec/rspec-expectations#581)change(obj, :msg)
form of the change matcher but forget the message argument. (Alex
Sunderland, rspec/rspec-expectations#585)contain_exactly matcher work with arrays that contain hashes in
arbitrary ordering. (Sam Phippen, rspec/rspec-expectations#578)Bug Fixes:
require that would cause the respond_to matcher to
fail when used in a project where the rest of RSpec (e.g. core and
expecatations) weren't being used. (Myron Marston, rspec/rspec-expectations#566)No code changes. Just taking it out of pre-release.
Breaking Changes for 3.0.0:
matcher_execution_context attribute from DSL-defined
custom matchers. (Myron Marston)RSpec::Matchers::Pretty#_pretty_print. (Myron Marston)RSpec::Matchers::Pretty#expected_to_sentence. (Myron Marston)RSpec::Matchers::Configuration constant to
RSpec::Expectations::Configuration. (Myron Marston)have_xyz predicate matchers using private methods.
(Adrian Gonzalez)supports_block_expectations?.
(Myron Marston)require 'rspec-expectations'.
Use require 'rspec/expectations' instead. (Myron Marston)Bug Fixes:
NoMethodError triggered by beta2 when YARD was loaded in
the test environment. (Myron Marston)be_xyz matcher to accept a do...end block. (Myron Marston)$stdout or $stderr.
(Myron Marston)change matcher to work properly with IO objects.
(Myron Marston)exist matcher so that it can be used in composed matcher
expressions involving objects that do not implement exist? or
exists?. (Daniel Fone)actual value.
(Myron Marston)be_xyz and has_xyz predicate matchers so that they can
be used in composed matcher expressions involving objects that
do not implement the predicate method. (Daniel Fone)Enhancements:
eq matcher failure
messages. (Daniel Fone)be_xyz predicate matchers so
that it includes the inspect output of the receiver.
(Erik Michaels-Ober, Sam Phippen)all matcher, 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)&/|) for compound operators (and/or). (Adam Farhi)expect { 3 }.to eq(3))
or vice versa. (Myron Marston)Breaking Changes for 3.0.0:
RSpec constant using
Rspec or Spec. (Myron Marston)RSpec::Expectations.differ=. (Myron Marston)expect(...).should. (Myron Marston)expect { }.not_to change { } with by,
by_at_least, by_at_most or to. These have never been supported
but did not raise explicit errors. (Myron Marston)=== rather than == as an alias of matches? for
all matchers. The semantics of === are closer to an RSpec
matcher than ==. (Myron Marston)RSpec::Matchers::OperatorMatcher constant.
(Myron Marston)RSpec::Expectations::ExpectationNotMetError subclass
Exception rather than StandardError so they can bypass
a bare rescue in end-user code (e.g. when an expectation is
set from within a rspec-mocks stub implementation). (Myron Marston)Enhancements:
be matcher when matching against:
true, false and nil. (Sam Phippen)expect syntax. If you want your matchers to
maintain compatibility with multiple versions of RSpec, you can
alias the new names to the old. (Myron Marston)
failure_message_for_should => failure_messagefailure_message_for_should_not => failure_message_when_negatedmatch_for_should => matchmatch_for_should_not => match_when_negatedchange matcher. (Myron Marston)and and or.
Simply chain them off of any existing matcher to create an expression
like expect(alphabet).to start_with("a").and end_with("z").
(Eloy Espinaco)contain_exactly as a less ambiguous version of match_array.
Note that it expects the expected array to be splatted as
individual args: expect(array).to contain_exactly(1, 2) is
the same as expect(array).to match_array([1, 2]). (Myron Marston)contain_exactly/match_array so that it can match against
other non-array collections (such as a Set). (Myron Marston)RSpec::Matchers::Composable mixin that can be used to make
a custom matcher composable as well. Note that custom matchers
defined via RSpec::Matchers.define already have this. (Myron
Marston)RSpec::Matchers.alias_matcher so users can define their own
matcher aliases. The description of the matcher will reflect the
alternate matcher name. (Myron Marston)be_between matcher. be_between has worked for a
long time as a dynamic predicate matcher, but the failure message
was suboptimal. The new matcher provides a much better failure
message. (Erik Michaels-Ober)be_between matcher to allow for inclusive or exclusive
comparison (e.g. inclusive of min/max or exclusive of min/max).
(Pedro Gimenez)not_to be #{operator} less confusing by
only saying it's confusing when comparison operators are used.
(Prathamesh Sonpatki)eq matcher when Time or DateTime
objects are used so that the full sub-second precision is included.
(Thomas Holmes, Jeff Wallace)output matcher for expecting that a block outputs to_stdout
or to_stderr. (Luca Pette, Matthias Günther)has_xyz? method call when
the have_xyz matcher is used. (Damian Galarza)rspec/expectations/minitest_integration after loading minitest
to use rspec-expectations with minitest. (Myron Marston)Bug Fixes:
expect { }.not_to change { }.from(x) so that the matcher only
passes if the starting value is x. (Tyler Rick, Myron Marston)ArgumentError when given an object of the wrong type to match
against, so that they work well in composite matcher expressions like
expect([1.51, "foo"]).to include(a_string_matching(/foo/), a_value_within(0.1).of(1.5)).
(Myron Marston)Deprecations:
shoulda), but it will print
a deprecation warning. (Myron Marston)Breaking Changes for 3.0.0:
be_close matcher, preferring be_within instead.
(Sam Phippen)have, have_at_least and have_at_most matchers.
You can continue using those matchers through https://github.com/rspec/rspec-collection_matchers,
or you can rewrite your expectations with something like
expect(your_object.size).to eq(num). (Hugo Baraúna)be_true and be_false to be_truthy and be_falsey. (Sam Phippen)expect { }.to_not raise_error(SomeSpecificClass, message),
expect { }.to_not raise_error(SomeSpecificClass) and
expect { }.to_not raise_error(message) invalid, since they are prone
to hiding failures. Instead, use expect { }.to_not raise_error (with no
args). (Sam Phippen)RSpec::Matchers.define blocks, helper methods made available
either via def self.helper or extend HelperModule are no longer
available to the match block (or any of the others). Instead
include your helper module and define the helper method as an
instance method. (Myron Marston)Enhancements:
do..end style block with raise_error matcher. (Yuji Nakayama)return from within custom matcher DSL blocks. (Myron
Marston)chain can now accept a block. (Myron
Marston)raise_error matcher via a chained
with_message method call. (Sam Phippen)Bug Fixes:
include and match matchers to be used from within a
DSL-defined custom matcher's match block. (Myron Marston)Deprecations:
:should syntax without explicitly configuring it is deprecated.
It will continue to work but will emit a deprecation warning in RSpec 3 if
you do not explicitly enable it. (Sam Phippen)Bug Fixes:
Expectations#method_handle_for where proxy objects
with method delegated would wrongly not return a method handle.
(Jon Rowe, rspec/rspec-expectations#594)Bug Fixes:
expected deprecation warning -- it's
expected_as_array, not expected_array. (Frederick Cheung, rspec/rspec-expectations#562)Enhancements:
errors_on with rspec-rails to be more useful.
(Aaron Kromer)Deprecations:
matcher_execution_context attribute on DSL-defined
custom matchers. (Myron Marston)RSpec::Matchers::Pretty#_pretty_print. (Myron Marston)RSpec::Matchers::Pretty#expected_to_sentence. (Myron Marston)RSpec::Matchers::Configuration in favor of
RSpec::Expectations::Configuration. (Myron Marston)be_xyz predicate matcher on an object that doesn't respond to
xyz? or xyzs?. (Daniel Fone)have_xyz matcher on an object that doesn't respond to has_xyz?.
(Daniel Fone)have_xyz matcher on an object that has a private method has_xyz?.
(Jon Rowe)supports_block_expectations?. (Myron Marston)require 'rspec-expectations'. Use
require 'rspec/expectations' instead. (Myron Marston)Deprecations:
by, by_at_least, by_at_most or to off of
expect { }.not_to change { }. The docs have always said these are
not supported for the negative form but now they explicitly raise
errors in RSpec 3. (Myron Marston)expect { }.not_to change { x }.from(y).
In RSpec 2.x, this expectation would only fail if x started with
the value of y and changed. If it started with a different value
and changed, it would pass. In RSpec 3, it will pass only if the
value starts at y and it does not change. (Myron Marston)matcher == value as an alias for matcher.matches?(value),
in favor of matcher === value. (Myron Marston)RSpec::Matchers::OperatorMatcher in favor of
RSpec::Matchers::BuiltIn::OperatorMatcher. (Myron Marston)RSpec::Matchers in the appropriate test case
base class yourself. (Myron Marston)#expected on a DSL-generated custom matcher
as an array when only 1 argument is passed to the matcher method.
In RSpec 3 it will be the single value in order to make diffs
work properly. (Jon Rowe)Deprecations
have, have_at_least and have_at_most. You can continue using those
matchers through https://github.com/rspec/rspec-collection_matchers, or
you can rewrite your expectations with something like
expect(your_object.size).to eq(num). (Hugo Baraúna)be_xyz predicate matcher when xyz? is a private method.
(Jon Rowe)be_true/be_false in favour of be_truthy/be_falsey
(for Ruby's conditional semantics) or be true/be false
(for exact equality). (Sam Phippen)def self.foo / extend Helper can be used to add macro methods
(e.g. methods that call the custom matcher DSL methods), but should
not be used to define helper methods called from within the DSL
blocks.def foo / include Helper is the opposite: it's for helper methods
callable from within a DSL block, but not for defining macros.Bug fixes
Bug fixes
match matcher produce a diff output. (Jon Rowe, Ben Moss)Bug fixes
should syntax) when method is redefined on target.
(Brandon Turner)should syntax) when operator is defined via
method_missing (Jon Rowe)Bug fixes
be_<predicate> matcher to not support operator chaining like the
be matcher does (e.g. be == 5). This led to some odd behaviors
since be_<predicate> == anything returned a BeComparedTo matcher
and was thus always truthy. This was a consequence of the implementation
(e.g. subclassing the basic Be matcher) and was not intended behavior.
(Myron Marston).change matcher to compare using == in addition to ===. This
is important for an expression like:
expect {}.to change { a.class }.from(ClassA).to(ClassB) because
SomeClass === SomeClass returns false. (Myron Marston)Bug fixes
Encoding::UndefinedConversionError
errors (Jon Rowe).Bug fixes
#inspect, rather than #description for
documentation output (Andy Lindeman, Sam Phippen).expect(a).to be_within(x).percent_of(y) work with negative y
(Katsuhiko Nishimra).be_predicate matcher work as expected used with expect{...}.to change... (Sam Phippen).Enhancements
yield_control so that you can specify an exact or relative
number of times: expect { }.to yield_control.exactly(3).times,
expect { }.to yield_control.at_least(2).times, etc (Bartek
Borkowski).:to_str as expectation messages.
(Toby Ovod-Everett)Bug fixes
expect(something).to be_within(x).percent_of(y) where x and y are both
integers (Sam Phippen).have matcher to handle the fact that on ruby 2.0,
Enumerator#size may return nil (Kenta Murata).expect { raise s }.to raise_error(s) where s is an error instance
on ruby 2.0 (Sam Phippen).expect(object).to raise_error passing. This now warns the user and
fails the spec (tomykaira).Deprecations
expect { }.not_to raise_error(SpecificErrorClass) or
expect { }.not_to raise_error("some specific message"). Using
these was prone to hiding failures as they would allow any other
error to pass. (Sam Phippen and David Chelimsky)Enhancements
be_within matcher:
expect(value).to be_within(10).percent_of(expected)
(Myron Marston).include matcher to allow it to be given a list
of matchers as the expecteds to match against (Luke Redpath).Bug fixes
change matcher so that it dups strings in order to handle
mutated strings (Myron Marston).should be =~ /some regex/ / expect(...).to be =~ /some regex/.
Previously, these either failed with a confusing undefined method matches?' for false:FalseClass error or were no-ops that didn't
actually verify anything (Myron Marston).undefined method #split for Array error when dumping
the diff of an array of multiline strings (Myron Marston).Bug fixes
{}.should =~ {}. (Myron Marston and Andy Lindeman)match_regex alias so that custom matchers
built using the matcher DSL can use it (since match
is a different method in that context).
(Steven Harman)Enhancements
--color option is configured. (Alex Coplan)raise_error
matcher (Myron Marston)=~ and match_array matchers output a more useful error message when
the actual value is not an array (or an object that responds to #to_ary)
(Sam Phippen)Bug fixes
include matcher so that expect({}).to include(:a => nil)
fails as it should (Sam Phippen).be_an_instance_of matcher so that Class#to_s is used in the
description rather than Class#inspect, since some classes (like
ActiveRecord::Base) define a long, verbose #inspect.
(Tom Stuart)Bug fixes
Fix (and deprecate) expect { }.should syntax so that it works even
though it was never a documented or intended syntax. It worked as a
consequence of the implementation of expect in RSpec 2.10 and
earlier. (Myron Marston)
Ensure #== is defined on built in matchers so that they can be composed. For example:
expect { user.emailed! }.to change { user.last_emailed_at }.to be_within(1.second).of(Time.zone.now)
Bug fixes
should and should_not on Object rather than BasicObject
on MacRuby. On MacRuby, BasicObject is defined but is not the root
of the object hierarchy. (Gabriel Gilder)Bug fixes
actual in be_within matcher to values that respond to - instead
of requiring a specific type.
Time, for example, is a legit alternative.Enhancements
expect syntax so that it supports expections on bare values
in addition to blocks (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 DelegatorBug fixes
Numeric values to be the "actual" in the be_within matcher.
This prevents confusing error messages. (Su Zhang @zhangsu)should and should_not on BasicObject rather than Kernel
on 1.9. This makes should and should_not work properly with
BasicObject-subclassed proxy objects like Delegator. (Myron
Marston)Enhancements
start_with and end_with matchers (Jeremy Wadsack)expect {...}.to yield_controlexpect {...}.to yield_with_args(1, 2, 3)expect {...}.to yield_with_no_argsexpect {...}.to yield_successive_args(1, 2, 3)match_unless_raises takes multiple exception argsBug fixes
be_within matcher to be inclusive of delta.Bug fixes
Enhancements
Bug fixes
respond_to? and method_missing in DSL-defined matchers.Enhancements
No changes for this release. Just releasing with the other rspec gems.
Enhancements
Enhancements
HaveMatcher converts argument using to_i (Alex Bepple & Pat Maddox)have_xxx matcher (Myron Marston)HaveMatcher supports count (Matthew Bellantoni)Enumerable before the action, supporting custom
Enumerable types like CollectionProxy in Rails (David Chelimsky)Bug fixes
have(n).xyz documentation (Jean Boussier)safe_sort for ruby 1.9.2 (Kernel now defines <=> for Object) (Peter
van Hardenberg)Enhancements
change matcher accepts regexps (Robert Davis)have_xxx matchers (Magnus Bergmark)range.should cover(*values) (Anders Furseth)Bug fixes
Enhancements
should exist works with exist? or exists? (Myron Marston)expect { ... }.not_to do_something (in addition to to_not)Documentation
No functional changes in this release, which was made to align with the rspec-core-2.4.0 release.
Enhancements
Enhancements
Enhancements
be_within(delta).of(expected) matcher (Myron Marston)should != expected on Ruby-1.9 (Myron Marston)throw_symbol (Myron Marston)Bug fixes
RSpec::Core (Myron Marston)have_matcher - use pluralize only when ActiveSupport inflections are indeed
defined (Josep M Bach)Enhancements
Bug fixes
respond_to matcher works correctly with should_not with multiple methods
(Myron Marston)include matcher works correctly with should_not with multiple values
(Myron Marston)Enhancements
require 'rspec/expectations' in a T::U or MiniUnit suite (Josep M. Bach)Bug fixes
Enhancements
Bug fixes
* should[_not] change now handles boolean values correctly