From accd9b4634f1a2f220bc3e38cf5c4add04186fe6 Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Fri, 25 Sep 2009 21:32:28 -0500 Subject: Restore "Start Rails::Application object This reverts commit f14ad4145622f45e9bf7433b5fdef4ce427efe4b. --- railties/test/application/load_test.rb | 56 ++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 railties/test/application/load_test.rb (limited to 'railties/test/application/load_test.rb') diff --git a/railties/test/application/load_test.rb b/railties/test/application/load_test.rb new file mode 100644 index 0000000000..6dda47bb8f --- /dev/null +++ b/railties/test/application/load_test.rb @@ -0,0 +1,56 @@ +require "isolation/abstract_unit" +require "rails" +require "rack" + +module ApplicationTests + class LoadTest < Test::Unit::TestCase + include ActiveSupport::Testing::Isolation + + def setup + build_app + end + + test "rails app is present" do + assert File.exist?(app_path("config")) + end + + test "running Rails::Application.load on the path returns a (vaguely) useful application" do + @app = Rails::Application.load app_path + assert_welcome get("/") + end + + test "config.ru is used" do + app_file "config.ru", <<-CONFIG + class MyMiddleware + def initialize(app) + @app = app + end + + def call(env) + status, headers, body = @app.call(env) + headers["Config-Ru-Test"] = "TESTING" + [status, headers, body] + end + end + + use MyMiddleware + run proc {|env| [200, {"Content-Type" => "text/html"}, ["VICTORY"]] } + CONFIG + + @app = Rails::Application.load app_path, :config => "config.ru" + + assert_body "VICTORY", get("/omg") + assert_header "Config-Ru-Test", "TESTING", get("/omg") + end + + test "arbitrary.rb can be used as a config" do + app_file "myapp.rb", <<-CONFIG + Myapp = proc {|env| [200, {"Content-Type" => "text/html"}, ["OMG ROBOTS"]] } + CONFIG + + @app = Rails::Application.load app_path, :config => "myapp.rb" + + assert_body "OMG ROBOTS", get("/omg") + end + end +end -- cgit v1.2.3