Sha256: e2804519ed94bf9d9ab225182fd4be53866006d40815c5cb6fb2e0479f75ada2

Contents?: true

Size: 865 Bytes

Versions: 9

Compression:

Stored size: 865 Bytes

Contents

require 'rack/lock'
require 'rack/mock'

class Lock
  attr_reader :synchronized

  def initialize
    @synchronized = false
  end

  def synchronize
    @synchronized = true
    yield
  end
end

describe Rack::Lock do
  should "call synchronize on lock" do
    lock = Lock.new
    env = Rack::MockRequest.env_for("/")
    app = Rack::Lock.new(lambda { |inner_env| }, lock)
    lock.synchronized.should.equal false
    app.call(env)
    lock.synchronized.should.equal true
  end

  should "set multithread flag to false" do
    app = Rack::Lock.new(lambda { |env| env['rack.multithread'] })
    app.call(Rack::MockRequest.env_for("/")).should.equal false
  end

  should "reset original multithread flag when exiting lock" do
    app = Rack::Lock.new(lambda { |env| env })
    app.call(Rack::MockRequest.env_for("/"))['rack.multithread'].should.equal true
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
rack-1.2.8 test/spec_lock.rb
rack-1.2.7 test/spec_lock.rb
rack-1.2.6 test/spec_lock.rb
rack-1.2.5 test/spec_lock.rb
rack-1.2.4 test/spec_lock.rb
rack-1.2.3 test/spec_lock.rb
rack-1.2.2 test/spec_lock.rb
rack-1.2.1 test/spec_lock.rb
rack-1.2.0 spec/spec_lock.rb