1
0
Fork 0
mirror of https://github.com/sinatra/sinatra synced 2023-03-27 23:18:01 -04:00
sinatra/test/rack_test.rb
Vipul A M 23c2e197c8 - Removed test-unit dependency
- updated minitest to 5.0
- Removed Test::Unit::TestCase and started using Minitest::Test instead
- Fixed usage of assert_raise
- Fixed usage of refute_nil
- Fixed and removed usage of assert_nothing_raised
2015-01-11 01:00:47 +05:30

45 lines
1 KiB
Ruby

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