Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/dart/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Multithreading 如何在单个线程中运行单个规范?_Multithreading_Rspec - Fatal编程技术网

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