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 Delegator
Bug 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_control
expect {...}.to yield_with_args(1, 2, 3)
expect {...}.to yield_with_no_args
expect {...}.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