Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add tests to check compatiblity with Rack::Lock, related to #352

  • Loading branch information...
commit 354ca5c2abb2c7f441f28645f52382f745f0711e 1 parent a0894fa
@rkh rkh authored
Showing with 45 additions and 0 deletions.
  1. +45 −0 test/rack_test.rb
View
45 test/rack_test.rb
@@ -0,0 +1,45 @@
+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
Please sign in to comment.
Something went wrong with that request. Please try again.