Skip to content

Commit 5bd65bc

Browse files
committed
improve run_spec, move Kemal configuration to run method and update server bind ports
1 parent e684d2e commit 5bd65bc

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

spec/run_spec.cr

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ require "./spec_helper"
33
private def run(code)
44
code = <<-CR
55
require "./src/kemal"
6+
7+
Kemal.config.env = "test"
8+
Kemal.config.port = 8000
9+
610
#{code}
711
CR
812

@@ -16,7 +20,6 @@ end
1620
describe "Run" do
1721
it "runs a code block after starting" do
1822
run(<<-CR).should contain("started")
19-
Kemal.config.env = "test"
2023
Kemal.run do
2124
log "started"
2225
end
@@ -25,7 +28,6 @@ describe "Run" do
2528

2629
it "runs a code block after stopping" do
2730
run(<<-CR).should contain("stopped")
28-
Kemal.config.env = "test"
2931
Kemal.run do
3032
Kemal.stop
3133
log "stopped"
@@ -35,23 +37,21 @@ describe "Run" do
3537

3638
it "runs without a block being specified" do
3739
run(<<-CR).should contain "[test] Kemal is running in test mode."
38-
Kemal.config.env = "test"
3940
Kemal.run
4041
Kemal.config.running
4142
CR
4243
end
4344

4445
it "allows custom HTTP::Server bind" do
4546
run(<<-CR).should contain "[test] Kemal is running in test mode."
46-
Kemal.config.env = "test"
4747
Kemal.run do |config|
4848
server = config.server.not_nil!
4949
5050
{% if flag?(:windows) %}
51-
server.bind_tcp "127.0.0.1", 3000
51+
server.bind_tcp "127.0.0.1", 8000
5252
{% else %}
53-
server.bind_tcp "127.0.0.1", 3000, reuse_port: true
54-
server.bind_tcp "0.0.0.0", 3001, reuse_port: true
53+
server.bind_tcp "127.0.0.1", 8000, reuse_port: true
54+
server.bind_tcp "0.0.0.0", 8001, reuse_port: true
5555
{% end %}
5656
end
5757
CR

0 commit comments

Comments
 (0)