Use filters to wrap examples into a pending block?

Hi all,

I was wonder whether something like the following is possible in RSpec?

RSpec.configure do |c|
c.filter_examples : pending_for_some_reason => lambda {|example|
pending “This example is failing due to upgrade of x” do
example.call
end
}
end

it “should succeed, but probably doesn’t yet”, :pending_for_some_reason
=>
true do
raise “fail”
end

I’m currently working on a library that has many failing specs due to an
upgrade of a dependency. It would be nice if a could just flag examples
that
are failing due to that change without having to copy paste the pending
block.

Cheers,
Jeroen

Found the answer by looking at the features:

RSpec.configure do |c|
c.around do |example|
if example.metadata.has_key?(:broken)
pending “is broken since change from 3.0.0.beta4 to 3.0.3” do
example.call
end
end
end
end

Nice :slight_smile:

On Thu, Dec 23, 2010 at 11:57 AM, Jeroen van Dijk <

Oh and don’t forget the ‘else’ part:

RSpec.configure do |c|
c.around do |example|
if example.metadata.has_key?(:broken)
pending “is broken since change from 3.0.0.beta4 to 3.0.3” do
example.call
end
else
example.call
end
end
end

Suddenly my test suite was mega fast and I had no failing specs… oops
:slight_smile:

Cheers

On Thu, Dec 23, 2010 at 12:40 PM, Jeroen van Dijk <