Sha256: d25cd4c06a89d7c2a5e90ca8bb9cf150ccb17e2dc5c3a0f6d58170ee293d44ba

Contents?: true

Size: 720 Bytes

Versions: 4

Compression:

Stored size: 720 Bytes

Contents

ruby_version_is "".."1.9" do
  require 'thread'

  describe "Thread.exclusive" do
    before :each do
      ScratchPad.clear
    end

    it "sets Thread.critical to true and yields" do
      Thread.exclusive { ScratchPad.record Thread.critical }
      ScratchPad.recorded.should == true
    end

    it "returns the result of yielding" do
      Thread.exclusive { :result }.should == :result
    end

    it "resets Thread.critical after yielding" do
      Thread.exclusive {}
      Thread.critical.should be_false
    end

    it "resets Thread.critical if the block raises" do
      lambda { Thread.exclusive { raise Exception } }.should raise_error(Exception)
      Thread.critical.should be_false
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rubysl-thread-2.1 spec/exclusive_spec.rb
rubysl-thread-2.0.3 spec/exclusive_spec.rb
rubysl-thread-2.0.2 spec/exclusive_spec.rb
rubysl-thread-1.0.0 spec/exclusive_spec.rb