config.ru 843 B

12345678910111213141516171819202122232425262728293031
  1. require "#{File.dirname(__FILE__)}/../testrequest"
  2. $stderr = File.open("#{File.dirname(__FILE__)}/log_output", "w")
  3. class EnvMiddleware
  4. def initialize(app)
  5. @app = app
  6. end
  7. def call(env)
  8. # provides a way to test that lint is present
  9. if env["PATH_INFO"] == "/broken_lint"
  10. return [200, {}, ["Broken Lint"]]
  11. # provides a way to kill the process without knowing the pid
  12. elsif env["PATH_INFO"] == "/die"
  13. exit!
  14. end
  15. env["test.$DEBUG"] = $DEBUG
  16. env["test.$EVAL"] = BUKKIT if defined?(BUKKIT)
  17. env["test.$VERBOSE"] = $VERBOSE
  18. env["test.$LOAD_PATH"] = $LOAD_PATH
  19. env["test.stderr"] = File.expand_path($stderr.path)
  20. env["test.Ping"] = defined?(Ping)
  21. env["test.pid"] = Process.pid
  22. @app.call(env)
  23. end
  24. end
  25. use EnvMiddleware
  26. run TestRequest.new