1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/railties/test/application/rack/logger_test.rb

59 lines
1.3 KiB
Ruby
Raw Normal View History

# frozen_string_literal: true
require "isolation/abstract_unit"
require "active_support/log_subscriber/test_helper"
require "rack/test"
module ApplicationTests
module RackTests
2012-01-05 20:30:17 -05:00
class LoggerTest < ActiveSupport::TestCase
2012-06-19 22:21:00 -04:00
include ActiveSupport::Testing::Isolation
include ActiveSupport::LogSubscriber::TestHelper
include Rack::Test::Methods
def setup
build_app
add_to_config <<-RUBY
config.logger = ActiveSupport::LogSubscriber::TestHelper::MockLogger.new
RUBY
require "#{app_path}/config/environment"
super
end
def teardown
2012-06-19 22:21:00 -04:00
super
teardown_app
end
def logs
@logs ||= Rails.logger.logged(:info).join("\n")
end
test "logger logs proper HTTP GET verb and path" do
get "/blah"
wait
assert_match 'Started GET "/blah"', logs
end
test "logger logs proper HTTP HEAD verb and path" do
head "/blah"
wait
assert_match 'Started HEAD "/blah"', logs
end
test "logger logs HTTP verb override" do
post "/", _method: "put"
wait
assert_match 'Started PUT "/"', logs
end
test "logger logs HEAD requests" do
post "/", _method: "head"
wait
assert_match 'Started HEAD "/"', logs
end
end
end
end