Sha256: 55efa10ae20b22ba02d98aa386ab93d6ed99a6dd317b21110af3e0371172c288

Contents?: true

Size: 925 Bytes

Versions: 35

Compression:

Stored size: 925 Bytes

Contents

require 'test/spec'

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

context "Rack::Lock" do
  class Lock
    attr_reader :synchronized

    def initialize
      @synchronized = false
    end

    def synchronize
      @synchronized = true
      yield
    end
  end

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

  specify "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

  specify "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

35 entries across 34 versions & 12 rubygems

Version Path
kjvarga-rack-1.0.0 test/spec_rack_lock.rb
qoobaa-rack-1.0.0.1 test/spec_rack_lock.rb
qoobaa-rack-1.0.2 test/spec_rack_lock.rb
timocratic-rack-1.0.0 test/spec_rack_lock.rb
rack-1.1.6 test/spec_rack_lock.rb
rack-1.1.5 test/spec_rack_lock.rb
rack-1.1.4 test/spec_rack_lock.rb
radiant-1.0.0 ruby-debug/ruby/1.8/gems/rack-1.1.3/test/spec_rack_lock.rb
rack-1.1.3 test/spec_rack_lock.rb
vanity-1.7.1 vendor/ruby/1.9.1/gems/rack-1.1.2/test/spec_rack_lock.rb
rack-1.1.2 test/spec_rack_lock.rb
rack-1.1.1 test/spec_rack_lock.rb
rack-1.1.1.pre test/spec_rack_lock.rb
eac-rack-1.1.1 test/spec_rack_lock.rb
akamai_bookmarklet-0.1.2 vendor/gems/ruby/1.8/gems/rack-1.1.0/test/spec_rack_lock.rb
middleman-0.13.1 lib/middleman/vendor/gems/ruby/1.8/gems/rack-1.1.0/test/spec_rack_lock.rb
middleman-0.13.1 lib/middleman/vendor/gems/ruby/1.9.1/gems/rack-1.1.0/test/spec_rack_lock.rb
akamai_bookmarklet-0.1.1 vendor/gems/ruby/1.8/gems/rack-1.1.0/test/spec_rack_lock.rb
akamai_bookmarklet-0.1.0 vendor/gems/ruby/1.8/gems/rack-1.1.0/test/spec_rack_lock.rb
rack-1.1.0 test/spec_rack_lock.rb