Sha256: 7b4f86420a097171209c05c3f6767ca3af1f5cdc52c22b4bf07d6e884e4bfbce

Contents?: true

Size: 1.03 KB

Versions: 65

Compression:

Stored size: 1.03 KB

Contents

require File.expand_path('../helper', __FILE__)
require 'rack'

class RackTest < Minitest::Test
  setup do
    @foo = Sinatra.new { get('/foo') { 'foo' }}
    @bar = Sinatra.new { get('/bar') { 'bar' }}
  end

  def build(*middleware)
    endpoint = middleware.pop
    @app = Rack::Builder.app do
      middleware.each { |m| use m }
      run endpoint
    end
  end

  def check(*middleware)
    build(*middleware)
    assert get('/foo').ok?
    assert_body 'foo'
    assert get('/bar').ok?
    assert_body 'bar'
  end

  it 'works as middleware in front of Rack::Lock, with lock enabled' do
    @foo.enable :lock
    check(@foo, Rack::Lock, @bar)
  end

  it 'works as middleware behind Rack::Lock, with lock enabled' do
    @foo.enable :lock
    check(Rack::Lock, @foo, @bar)
  end

  it 'works as middleware in front of Rack::Lock, with lock disabled' do
    @foo.disable :lock
    check(@foo, Rack::Lock, @bar)
  end

  it 'works as middleware behind Rack::Lock, with lock disabled' do
    @foo.disable :lock
    check(Rack::Lock, @foo, @bar)
  end
end

Version data entries

65 entries across 62 versions & 18 rubygems

Version Path
logstash-output-scalyr-0.2.1.beta vendor/bundle/jruby/2.5.0/gems/sinatra-1.4.8/test/rack_test.rb
logstash-output-scalyr-0.2.0 vendor/bundle/jruby/2.5.0/gems/sinatra-1.4.8/test/rack_test.rb
logstash-output-scalyr-0.2.0.beta vendor/bundle/jruby/2.5.0/gems/sinatra-1.4.8/test/rack_test.rb
logstash-output-scalyr-0.1.26.beta vendor/bundle/jruby/2.5.0/gems/sinatra-1.4.8/test/rack_test.rb
logstash-output-scalyr-0.1.25.beta vendor/bundle/jruby/2.5.0/gems/sinatra-1.4.8/test/rack_test.rb
logstash-output-scalyr-0.1.24.beta vendor/bundle/jruby/2.5.0/gems/sinatra-1.4.8/test/rack_test.rb
logstash-output-scalyr-0.1.23.beta vendor/bundle/jruby/2.5.0/gems/sinatra-1.4.8/test/rack_test.rb
logstash-output-scalyr-0.1.22.beta vendor/bundle/jruby/2.5.0/gems/sinatra-1.4.8/test/rack_test.rb
logstash-output-scalyr-0.1.21.beta vendor/bundle/jruby/2.5.0/gems/sinatra-1.4.8/test/rack_test.rb
logstash-output-scalyr-0.1.20.beta vendor/bundle/jruby/2.5.0/gems/sinatra-1.4.8/test/rack_test.rb
logstash-output-scalyr-0.1.19.beta vendor/bundle/jruby/2.5.0/gems/sinatra-1.4.8/test/rack_test.rb
logstash-output-scalyr-0.1.18.beta vendor/bundle/jruby/2.5.0/gems/sinatra-1.4.8/test/rack_test.rb
logstash-output-scalyr-0.1.17.beta vendor/bundle/jruby/2.5.0/gems/sinatra-1.4.8/test/rack_test.rb
logstash-output-scalyr-0.1.16.beta vendor/bundle/jruby/2.5.0/gems/sinatra-1.4.8/test/rack_test.rb
logstash-output-scalyr-0.1.15.beta vendor/bundle/jruby/2.5.0/gems/sinatra-1.4.8/test/rack_test.rb
logstash-output-scalyr-0.1.14.beta vendor/bundle/jruby/2.5.0/gems/sinatra-1.4.8/test/rack_test.rb
logstash-output-scalyr-0.1.13 vendor/bundle/jruby/2.5.0/gems/sinatra-1.4.8/test/rack_test.rb
logstash-output-scalyr-0.1.12 vendor/bundle/jruby/2.5.0/gems/sinatra-1.4.8/test/rack_test.rb
logstash-output-scalyr-0.1.11.beta vendor/bundle/jruby/2.5.0/gems/sinatra-1.4.8/test/rack_test.rb
logstash-output-scalyr-0.1.10.beta vendor/bundle/jruby/2.5.0/gems/sinatra-1.4.8/test/rack_test.rb