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.1.9 vendor/bundle/jruby/2.5.0/gems/sinatra-1.4.8/test/rack_test.rb
logstash-output-scalyr-0.1.8 vendor/bundle/jruby/2.5.0/gems/sinatra-1.4.8/test/rack_test.rb
logstash-output-scalyr-0.1.7 vendor/bundle/jruby/2.5.0/gems/sinatra-1.4.8/test/rack_test.rb
logstash-output-scalyr-0.1.6 vendor/bundle/jruby/2.5.0/gems/sinatra-1.4.8/test/rack_test.rb
logstash-output-newrelic-1.2.0 vendor/bundle/jruby/2.5.0/gems/sinatra-1.4.8/test/rack_test.rb
logstash-filter-csharp-0.2.1 vendor/bundle/jruby/2.3.0/gems/sinatra-1.4.8/test/rack_test.rb
logstash-filter-csharp-0.2.1 vendor/bundle/jruby/2.5.0/gems/sinatra-1.4.8/test/rack_test.rb
logstash-filter-csharp-0.2.0 vendor/bundle/jruby/2.3.0/gems/sinatra-1.4.8/test/rack_test.rb
logstash-filter-csharp-0.2.0 vendor/bundle/jruby/2.5.0/gems/sinatra-1.4.8/test/rack_test.rb
logstash-output-scalyr-0.1.5 vendor/bundle/jruby/2.5.0/gems/sinatra-1.4.8/test/rack_test.rb
logstash-output-scalyr-0.1.4 vendor/bundle/jruby/2.5.0/gems/sinatra-1.4.8/test/rack_test.rb
logstash-output-scalyr-0.1.3 vendor/bundle/jruby/2.5.0/gems/sinatra-1.4.8/test/rack_test.rb
logstash-output-scalyr-0.1.2 vendor/bundle/jruby/2.5.0/gems/sinatra-1.4.8/test/rack_test.rb
logstash-filter-device_detection-1.0.7-java vendor/bundle/jruby/1.9/gems/sinatra-1.4.8/test/rack_test.rb
mrcooper-logstash-output-azuresearch-0.2.2 vendor/jruby/2.5.0/gems/sinatra-1.4.8/test/rack_test.rb
logstash-output-icinga-1.1.0 vendor/jruby/2.3.0/gems/sinatra-1.4.8/test/rack_test.rb
logstash-output-icinga-1.1.0 vendor/jruby/1.9/gems/sinatra-1.4.8/test/rack_test.rb
logstash-filter-cache-redis-0.3.1 vendor/bundle/jruby/1.9/gems/sinatra-1.4.8/test/rack_test.rb
logstash-filter-cache-redis-0.3.0 vendor/bundle/jruby/1.9/gems/sinatra-1.4.8/test/rack_test.rb
logstash-filter-cache-redis-0.2.0 vendor/bundle/jruby/1.9/gems/sinatra-1.4.8/test/rack_test.rb