In RSpec-1.0, we introduced a Not Yet Implemented feature. When you say …

it "should do something"

… with no block, the summary report lists that example as not implemented.

37 examples, 0 failures, 1 not implemented

As I started to use this I found myself doing stuff like this:

it "should do something"

do

here.is(the).actual(implementation).but(commented).out

end

This made me sad. I hate having things that are commented out like that, even if the summary report draws my attention to it.

<p>Then came a conversation with <a href="http://dannorth.net">Dan</a> about <a href="http://rbehave.rubyforge.org">rbehave</a>. In his article <a href="http://dannorth.net/2007/06/introducing-rbehave">introducing rbehave</a>, Dan talks about identifying pending scenarios so instead of getting failures while he&#8217;s working on the objects that must implement the behaviour, he gets a nice list of scenarios that should pass pending the completion of those objects. We discussed the similarities and differences between the Not Yet Implemented feature in RSpec and the Pending feature in rbehave and agreed that RSpec should have the pending method.</p>


<p>And so it has come to pass.</p>


<p>RSpec (trunk, as of rev 2118 &#8211; will be included in 1.0.6) still supports calling #it with no block, but now also supports the #pending method, allowing you to say:</p>

describe "pending example (using pending method)" do
  it %Q|should be reported as "PENDING: for some reason"| do
    pending("for some reason")
  end
end

describe "pending example (with no block)" do it %Q|should be reported as "PENDING: Not Yet Implemented"| end

And hear:

$ ruby bin/spec examples/pending_example.rb -fs

pending example (using pending method) - should be reported as "PENDING: for some reason" (PENDING: for some reason)

pending example (with no block) - should be reported as "PENDING: Not Yet Implemented" (PENDING: Not Yet Implemented)

Finished in 0.006639 seconds

2 examples, 0 failures, 2 pending

The #pending method raises a Spec::DSL::ExamplePendingError, which gets reported, in this case, as “PENDING: for some reason”. If you leave off the block the example will be reported as “PENDING: Not Yet Implemented”. Either way, the summary will combine these two types of pending examples as just “pending”.

2 Responses to “pending("insert reason here")”

  1. Chad Humphries Says:

    Very nice indeed.

  2. David Chelimsky Says:

    Chad – coming from one of the guys that implemented Not Yet Implemented, I’ll take that as a compliment! And thanks again for the original contribution.