Multithreading 如何在单个线程中运行单个规范?
我的规格:Multithreading 如何在单个线程中运行单个规范?,multithreading,rspec,Multithreading,Rspec,我的规格: it "has empty thread" do Thread.current[:foo].should be_nil Thread.current[:foo] = "bar" end it "has empty thread" do Thread.current[:foo].should be_nil end 第二个等级库失败,因为前一个等级库更改了线程。 如何在不同的线程中运行规范,或者在每个规范或其他东西通过第二个规范之前“清空”线程的键?您可以在规范中创建线程
it "has empty thread" do
Thread.current[:foo].should be_nil
Thread.current[:foo] = "bar"
end
it "has empty thread" do
Thread.current[:foo].should be_nil
end
第二个等级库失败,因为前一个等级库更改了线程。
如何在不同的线程中运行规范,或者在每个规范或其他东西通过第二个规范之前“清空”线程的键?您可以在规范中创建
线程
;别忘了加入以获得重新评估线程的应结果:
it "has empty thread" do
Thread.new {
Thread.current[:foo].should be_nil
Thread.current[:foo] = "bar"
}.join
end
it "has empty thread" do
Thread.new {
Thread.current[:foo].should be_nil
}.join
end
您可以在规范中创建线程
;别忘了加入以获得重新评估线程的应结果:
it "has empty thread" do
Thread.new {
Thread.current[:foo].should be_nil
Thread.current[:foo] = "bar"
}.join
end
it "has empty thread" do
Thread.new {
Thread.current[:foo].should be_nil
}.join
end