Skip to content

Commit

Permalink
clarify startup message in test mode (#687)
Browse files Browse the repository at this point in the history
  • Loading branch information
a-alhusaini authored Jul 30, 2024
1 parent 0afbd12 commit 3243b8e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions spec/run_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ describe "Run" do
end

it "runs without a block being specified" do
run(<<-CR).should eq "[test] Kemal is ready to lead at http://0.0.0.0:3000\ntrue\n"
run(<<-CR).should contain "[test] Kemal is running in test mode."
Kemal.config.env = "test"
Kemal.run
puts Kemal.config.running
CR
end

it "allows custom HTTP::Server bind" do
run(<<-CR).should eq "[test] Kemal is ready to lead at http://127.0.0.1:3000, http://0.0.0.0:3001\n"
run(<<-CR).should contain "[test] Kemal is running in test mode."
Kemal.config.env = "test"
Kemal.run do |config|
server = config.server.not_nil!
Expand Down
8 changes: 6 additions & 2 deletions src/kemal.cr
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,12 @@ module Kemal
end

def self.display_startup_message(config, server)
addresses = server.addresses.join ", " { |address| "#{config.scheme}://#{address}" }
log "[#{config.env}] #{config.app_name} is ready to lead at #{addresses}"
if config.env != "test"
addresses = server.addresses.join ", " { |address| "#{config.scheme}://#{address}" }
log "[#{config.env}] #{config.app_name} is ready to lead at #{addresses}"
else
log "[#{config.env}] #{config.app_name} is running in test mode. Server not listening"
end
end

def self.stop
Expand Down

0 comments on commit 3243b8e

Please sign in to comment.