2009-12-26 21:00:18 +01:00
|
|
|
require 'rack/builder'
|
|
|
|
require 'rack/config'
|
2010-06-14 06:09:24 +02:00
|
|
|
require 'rack/content_length'
|
|
|
|
require 'rack/lint'
|
|
|
|
require 'rack/mock'
|
2009-12-26 21:00:18 +01:00
|
|
|
|
2010-06-14 06:09:24 +02:00
|
|
|
describe Rack::Config do
|
|
|
|
should "accept a block that modifies the environment" do
|
2009-12-26 21:00:18 +01:00
|
|
|
app = Rack::Builder.new do
|
|
|
|
use Rack::Lint
|
|
|
|
use Rack::ContentLength
|
|
|
|
use Rack::Config do |env|
|
|
|
|
env['greeting'] = 'hello'
|
|
|
|
end
|
|
|
|
run lambda { |env|
|
|
|
|
[200, {'Content-Type' => 'text/plain'}, [env['greeting'] || '']]
|
|
|
|
}
|
|
|
|
end
|
2010-06-14 06:09:24 +02:00
|
|
|
|
2009-12-26 21:00:18 +01:00
|
|
|
response = Rack::MockRequest.new(app).get('/')
|
|
|
|
response.body.should.equal('hello')
|
|
|
|
end
|
|
|
|
end
|