Use of 'should' in another thread

Hi,

I’ve tried to find anything about using ‘should’ within a Thread, but
it is a little hard do look up there, so I hope you forgive-me if I am
asking an “old question”.

I guess this spec should fail:

describe Thread do
it “must be fine” do
Thread.new { true.should_not be_true } # Why don’t fail?!
end
end

It seems that some parts of RSpec are not thread safe. Right?

Thanks

On Jun 12, 2008, at 5:14 PM, Daniel L. wrote:

Thread.new { true.should_not be_true } # Why don’t fail?!
end
end

It seems that some parts of RSpec are not thread safe. Right?

If that’s running in a separate Thread and you’re not getting any
feedback, that suggests to me that it is in fact thread safe. Unless
I’m missing something. Which is entirely possible.

Cheers,
David

On Thu, Jun 12, 2008 at 6:14 PM, Daniel L.
[email protected]
wrote:

Thread.new { true.should_not be_true } # Why don’t fail?!
end
end

No, it’s because you aren’t waiting for the thread. Try:

describe Thread do
it “must be fine” do
t = Thread.new { true.should_not be_true }
t.join
end
end


Rick DeNatale

My blog on Ruby
http://talklikeaduck.denhaven2.com/