2011-07-24 5 views
1

マイスペック:シングルスレッドでシングルspeを実行するには?

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 

スレッドが前の仕様で変更されたため、第二のスペックが失敗しました。 スペックを別のスレッドで実行したり、各スペックの前にスレッドのキーを無効にしたり、別のスペックを渡す方法はありますか?

答えて

1

仕様にThreadを作成できます。 'joinを忘れないでくださいshouldの結果をスレッドから再評価しました:

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 
関連する問題