I just upgraded one of my Rails projects to Rspec 1.0.2, ran all my old specs to see what would happen, and … crunch. It turns out there are a few gotchas if you were using an older version (instead of starting from scratch–I think they’ll be picking up some new users with this release).
First thing to change in your specs:
context "a model or controller or whatever" do
specify "behavior" do
describe "a model or controller or whatever" do
it "has behavior" do
The description for model blocks should look like:
describe Apple, "with fixtures loaded" do
The string after the model name is optional.
For controller blocks it’s:
describe ApplesController do
You can also use a string in place of the controller name, in which case you’ll need to declare the controller name explicitly.
describe "Submitting new apple description"
The setup block is now before(:each).
[setup actions of some sort]
The syntax for ‘should’ functions has changed.
I had several examples of:
This is now:
Note the lack of an underscore after ‘should’.
The exception to that is the should_not function.
This is correct:
With these changes, all of my specs are passing again. Did I miss anything that broke for you? Leave a comment.