Notes:
This is the "Grow up and eat your own dog food release". RSpec is now used on itself and
we're no longer using Test::Unit to test it. Although, we are still extending Test::Unit
for the rails plugin (indirectly - through ZenTest)
IMPORTANT NOTE: THIS RELEASE IS NOT 100% BACKWARDS COMPATIBLE TO 0.6.x
There are a few changes that will require that you change your existing specs.
RSpec now handles equality exactly like ruby does:
# actual.should_equal(expected) will pass if actual.equal?(expected) returns true
# actual.should_eql(expected) will pass if actual.eql?(expected) returns true
# actual.should == expected will pass if actual == expected) returns true
At the high level, eql? implies equivalence, while equal? implies object identity. For more
information on how ruby deals w/ equality, you should do this:
ri equal?
or look at this:
http://www.ruby-doc.org/core/classes/Object.html#M001057
Also, we left in should_be as a synonym for should_equal, so the only specs that should break are the
ones using should_equal (which used to use <code>==</code> instead of <code>.equal?</code>).
Lastly, should_be used to handle true and false differently from any other values. We've removed
this special handling, so now actual.should_be true will fail for any value other than true (it
used to pass for any non-nil, non-false value), and actual.should_be false will fail for any
value other than false (it used to pass for nil or false).
Here's what you'll need to do to update your specs:
# search for "should_equal" and replace with "should_eql"
# run specs
If any specs still fail, they are probably related to should_be(true) or should_be(false) using
non-boolean values. Those you'll just have to inspect manually and adjust appropriately (sorry!).
--------------------------------------------------
Specifying multiple return values in mocks now works like this:
mock.should_receive(:message).and_return(1,2,3)
It used to work like this:
mock.should_receive(:message).and_return([1,2,3])
but we decided that was counter intuitive and otherwise lame.
Here's what you'll need to do to update your specs:
# search for "and_return(["
# get rid of the "[" and "]"
--------------------------------------------------
RSpec on Rails now supports the following (thanks to ZenTest upon which it is built):
# Separate specs for models, views, controllers and helpers
# Controller specs are completely decoupled from the views by default (though you can tell them to couple themselves if you prefer)
# View specs are completely decoupled from app-specific controllers
See http://rspec.rubyforge.org/documentation/rails/index.html for more information
Changes:
* Added lots of documentation on mocks/stubs and the rails plugin.
* Added support for assigns[key] syntax for controller specs (to align w/ pre-existing syntax for view specs)
* Added support for controller.should_redirect_to
* RSpec on Rails automatically checks whether it's compatible with the installed RSpec
* Applied [#6393] rspec_on_rails uses deprecated '@response' instead of the accessor
* RSpec now has 100% spec coverage(!)
* Added support for stubbing and partial mocking
* Progress (....F..F.) is now coloured. Tweaked patch from KAKUTANI Shintaro.
* Backtrace now excludes the rcov runner (/usr/local/bin/rcov)
* Fixed [#5539] predicates do not work w/ rails
* Added [#6091] support for Regexp matching messages sent to should_raise
* Added [#6333] support for Regexp matching in mock arguments
* Applied [#6283] refactoring of diff support to allow selectable formats and custom differs
* Fixed [#5564] "ruby spec_file.rb" doesn't work the same way as "spec spec_file.rb"
* Fixed [#6056] Multiple output of failing-spec notice
* Fixed [#6233] Colours in specdoc
* Applied [#6207] Allows --diff option to diff target and expected's #inspect output (Patch by Lachie Cox)
* Fixed [#6203] Failure messages are misleading - consider using inspect.
* Added [#6334] subject.should_have_xyz will try to call subject.has_xyz? - use this for hash.should_have_key(key)
* Fixed [#6017] Rake task should ignore empty or non-existent spec-dirs
|