[rspec-users] A recently observed anti pattern: commented out tests

Chris Flipse cflipse at gmail.com
Tue Jul 24 20:54:31 UTC 2012

On Tue, Jul 24, 2012 at 1:55 PM, James Cox <james at imaj.es> wrote:

> so yes, pending is ok, but a second keyword "broken" might be nicer,
> which would act the same but output different info.--

There is a block form of pending.  It actually executes the contents of the
block, but outputs as a pending test -- unless the test passes, in which
case it fails with a differing message:

  it "is a broken test that I need to fix sometime" do
    pending("broke on nonesuch upgrade") {

So,  that shows up in test output just like every other pending note.
Whenever someone gets around to fixing whatever failed, the contents of the
block start passing -- and the test will fail.  The failure is a signal to
remove the pending block from around the test.

This may not be as helpful as you like, if it's drowning in a sea of true
"pending" tests ... but I feel that leaving unimplemented, pending tests in
the suite for a long time is a Bad Thing -- precisely because you loose
useful information like this.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20120724/2b4af5e3/attachment.html>

More information about the rspec-users mailing list