Add test for HealthController

This commit is contained in:
Niklas Haeusele 2023-01-20 00:01:13 +01:00
parent 5c835bd669
commit 978edc24f4
1 changed files with 31 additions and 0 deletions

View File

@ -0,0 +1,31 @@
# frozen_string_literal: true
require "abstract_unit"
class HealthControllerTest < ActionController::TestCase
tests Rails::HealthController
def setup
Rails.application.routes.draw do
get "/up" => "rails/health#show"
end
@routes = Rails.application.routes
end
test "health controller renders green success page" do
get :show
assert_response :success
assert_match(/background-color: green/, @response.body)
end
test "health controller renders red internal server error page" do
@controller.instance_eval do
def render_up
raise Exception, "some exception"
end
end
get :show
assert_response :internal_server_error
assert_match(/background-color: red/, @response.body)
end
end