[rspec-users] inverse examples? (should fail)
Chris Anderson
jchris at mfdz.com
Sat Jun 23 12:36:06 EDT 2007
The new "pending" example feature reminds me of a feature I've been
bouncing around in my head, to aid in refactoring. Often, when I'm
changing existing behaviour, I know that certain aspects of the old
behaviour should change. Imagine changing the "it" method to perhaps
"not" or "old" or "removed"... The behaviour would be to raise a spec
error if the example DOES NOT fail. So if
it "should do something that's been deprecated" do
my_object.should_receive(:deprecated_message)
action
end
passes, than
old "should do something that's been deprecated" do
my_object.should_receive(:deprecated_message)
action
end
ought to fail.
It seems like this might be a good first line of defense when starting
a big refactor.
I'm not sure about the wording - maybe there's a better way of
expressing it - perhaps as a second argument to the spec (but that
would be a little less fun to pepper throughout a document).
it "should do something that's been deprecated", :inverse => true do
my_object.should_receive(:deprecated_message)
action
end
Thoughts? Does this exist already and I haven't noticed it?
--
Chris Anderson
http://jchris.mfdz.com
More information about the rspec-users
mailing list