Sha256: a025def76c326c241b67309e4c1bf696c2ff1ff20de2f974b313889f804aba55

Contents?: true

Size: 1.04 KB

Versions: 89

Compression:

Stored size: 1.04 KB

Contents

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

class RackTest < Test::Unit::TestCase
  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

89 entries across 87 versions & 10 rubygems

Version Path
classiccms-0.7.5 vendor/bundle/gems/sinatra-1.3.2/test/rack_test.rb
classiccms-0.7.4 vendor/bundle/gems/sinatra-1.3.2/test/rack_test.rb
classiccms-0.7.3 vendor/bundle/gems/sinatra-1.3.2/test/rack_test.rb
sinatra-acd-1.4.5 test/rack_test.rb
sinatra-1.4.5 test/rack_test.rb
mango-0.8.0 vendor/bundler/ruby/2.1.0/gems/sinatra-1.4.4/test/rack_test.rb
mango-0.7.1 vendor/bundler/ruby/2.0.0/gems/sinatra-1.4.4/test/rack_test.rb
mango-0.7.0 vendor/bundler/ruby/2.0.0/gems/sinatra-1.4.4/test/rack_test.rb
sinatra-1.4.4 test/rack_test.rb
torquebox-console-0.3.0 vendor/bundle/jruby/1.9/gems/sinatra-1.3.5/test/rack_test.rb
classiccms-0.7.2 vendor/bundle/gems/sinatra-1.3.2/test/rack_test.rb
classiccms-0.7.1 vendor/bundle/gems/sinatra-1.3.2/test/rack_test.rb
sinatra-1.4.3 test/rack_test.rb
classiccms-0.7.0 vendor/bundle/gems/sinatra-1.3.2/test/rack_test.rb
torquebox-console-0.2.5 vendor/bundle/jruby/1.9/gems/sinatra-1.3.5/test/rack_test.rb
torquebox-console-0.2.5 vendor/bundle/ruby/1.8/gems/sinatra-1.3.5/test/rack_test.rb
sinatra-1.4.2 test/rack_test.rb
sinatra-1.4.1 test/rack_test.rb
sinatra-1.4.0 test/rack_test.rb
sinatra-1.3.6 test/rack_test.rb