spec_config.rb 574 B

1234567891011121314151617181920212223
  1. require 'rack/builder'
  2. require 'rack/config'
  3. require 'rack/content_length'
  4. require 'rack/lint'
  5. require 'rack/mock'
  6. describe Rack::Config do
  7. should "accept a block that modifies the environment" do
  8. app = Rack::Builder.new do
  9. use Rack::Lint
  10. use Rack::ContentLength
  11. use Rack::Config do |env|
  12. env['greeting'] = 'hello'
  13. end
  14. run lambda { |env|
  15. [200, {'Content-Type' => 'text/plain'}, [env['greeting'] || '']]
  16. }
  17. end
  18. response = Rack::MockRequest.new(app).get('/')
  19. response.body.should.equal('hello')
  20. end
  21. end