2017-08-14 13:08:09 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2009-09-25 22:32:28 -04:00
|
|
|
require "isolation/abstract_unit"
|
|
|
|
|
|
|
|
module ApplicationTests
|
2012-01-05 20:30:17 -05:00
|
|
|
class RackupTest < ActiveSupport::TestCase
|
2009-09-25 22:32:28 -04:00
|
|
|
include ActiveSupport::Testing::Isolation
|
|
|
|
|
2009-09-28 20:57:36 -04:00
|
|
|
def rackup
|
2009-11-24 16:03:24 -05:00
|
|
|
require "rack"
|
2011-11-11 05:04:47 -05:00
|
|
|
app, _ = Rack::Builder.parse_file("#{app_path}/config.ru")
|
2009-11-25 17:45:12 -05:00
|
|
|
app
|
2009-09-28 20:57:36 -04:00
|
|
|
end
|
|
|
|
|
2009-09-25 22:32:28 -04:00
|
|
|
def setup
|
|
|
|
build_app
|
|
|
|
end
|
|
|
|
|
2011-06-04 15:15:52 -04:00
|
|
|
def teardown
|
2011-06-06 08:54:05 -04:00
|
|
|
teardown_app
|
2011-06-04 15:15:52 -04:00
|
|
|
end
|
|
|
|
|
2016-07-12 02:51:36 -04:00
|
|
|
test "Rails app is present" do
|
2009-09-25 22:32:28 -04:00
|
|
|
assert File.exist?(app_path("config"))
|
|
|
|
end
|
|
|
|
|
2009-09-28 20:57:36 -04:00
|
|
|
test "config.ru can be racked up" do
|
2009-12-23 22:10:44 -05:00
|
|
|
Dir.chdir app_path do
|
|
|
|
@app = rackup
|
|
|
|
assert_welcome get("/")
|
|
|
|
end
|
2009-09-25 22:32:28 -04:00
|
|
|
end
|
|
|
|
|
2009-09-28 20:57:36 -04:00
|
|
|
test "Rails.application is available after config.ru has been racked up" do
|
|
|
|
rackup
|
2010-05-19 15:14:51 -04:00
|
|
|
assert_kind_of Rails::Application, Rails.application
|
2009-09-28 20:57:36 -04:00
|
|
|
end
|
2009-09-25 22:32:28 -04:00
|
|
|
|
2009-09-28 20:57:36 -04:00
|
|
|
test "the config object is available on the application object" do
|
|
|
|
rackup
|
2016-08-06 13:16:09 -04:00
|
|
|
assert_equal "UTC", Rails.application.config.time_zone
|
2009-09-25 22:32:28 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|