Really fixing them would be nicer but that can be complicated, so just run them 3 times and if they fail every time fail, otherwise pass with warnings.
Code
def self.brittle_should(test, &block)
results = []
tries = 3
tries.times do |i|
should test + " (try #{i+1})" do
if results.empty? or results.none?
begin
instance_exec(&block)
results << true
rescue Object
if results.size < tries
warn "Brittle test #{test.inspect} failed, trying again..."
results << false
else
raise
end
end
end
end
end
end