puma 2.1.1 → 7.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (125) hide show
  1. checksums.yaml +7 -0
  2. data/History.md +3273 -0
  3. data/LICENSE +23 -20
  4. data/README.md +388 -100
  5. data/bin/puma-wild +25 -0
  6. data/bin/pumactl +1 -1
  7. data/docs/architecture.md +74 -0
  8. data/docs/compile_options.md +55 -0
  9. data/docs/deployment.md +137 -0
  10. data/docs/fork_worker.md +41 -0
  11. data/docs/images/puma-connection-flow-no-reactor.png +0 -0
  12. data/docs/images/puma-connection-flow.png +0 -0
  13. data/docs/images/puma-general-arch.png +0 -0
  14. data/docs/java_options.md +54 -0
  15. data/docs/jungle/README.md +9 -0
  16. data/docs/jungle/rc.d/README.md +74 -0
  17. data/docs/jungle/rc.d/puma +61 -0
  18. data/docs/jungle/rc.d/puma.conf +10 -0
  19. data/docs/kubernetes.md +73 -0
  20. data/docs/nginx.md +5 -5
  21. data/docs/plugins.md +42 -0
  22. data/docs/rails_dev_mode.md +28 -0
  23. data/docs/restart.md +65 -0
  24. data/docs/signals.md +98 -0
  25. data/docs/stats.md +148 -0
  26. data/docs/systemd.md +253 -0
  27. data/docs/testing_benchmarks_local_files.md +150 -0
  28. data/docs/testing_test_rackup_ci_files.md +36 -0
  29. data/ext/puma_http11/PumaHttp11Service.java +2 -2
  30. data/ext/puma_http11/extconf.rb +59 -2
  31. data/ext/puma_http11/http11_parser.c +319 -487
  32. data/ext/puma_http11/http11_parser.h +15 -13
  33. data/ext/puma_http11/http11_parser.java.rl +27 -43
  34. data/ext/puma_http11/http11_parser.rl +27 -24
  35. data/ext/puma_http11/http11_parser_common.rl +8 -8
  36. data/ext/puma_http11/mini_ssl.c +696 -38
  37. data/ext/puma_http11/no_ssl/PumaHttp11Service.java +15 -0
  38. data/ext/puma_http11/org/jruby/puma/Http11.java +145 -113
  39. data/ext/puma_http11/org/jruby/puma/Http11Parser.java +139 -172
  40. data/ext/puma_http11/org/jruby/puma/MiniSSL.java +413 -193
  41. data/ext/puma_http11/puma_http11.c +183 -175
  42. data/lib/puma/app/status.rb +77 -29
  43. data/lib/puma/binder.rb +349 -119
  44. data/lib/puma/cli.rb +164 -769
  45. data/lib/puma/client.rb +591 -132
  46. data/lib/puma/cluster/worker.rb +183 -0
  47. data/lib/puma/cluster/worker_handle.rb +127 -0
  48. data/lib/puma/cluster.rb +634 -0
  49. data/lib/puma/cluster_accept_loop_delay.rb +91 -0
  50. data/lib/puma/commonlogger.rb +115 -0
  51. data/lib/puma/configuration.rb +370 -202
  52. data/lib/puma/const.rb +266 -115
  53. data/lib/puma/control_cli.rb +219 -120
  54. data/lib/puma/detect.rb +45 -2
  55. data/lib/puma/dsl.rb +1496 -0
  56. data/lib/puma/error_logger.rb +115 -0
  57. data/lib/puma/events.rb +44 -60
  58. data/lib/puma/io_buffer.rb +48 -5
  59. data/lib/puma/jruby_restart.rb +2 -51
  60. data/lib/puma/json_serialization.rb +96 -0
  61. data/lib/puma/launcher/bundle_pruner.rb +104 -0
  62. data/lib/puma/launcher.rb +502 -0
  63. data/lib/puma/log_writer.rb +147 -0
  64. data/lib/puma/minissl/context_builder.rb +96 -0
  65. data/lib/puma/minissl.rb +355 -37
  66. data/lib/puma/null_io.rb +79 -12
  67. data/lib/puma/plugin/systemd.rb +90 -0
  68. data/lib/puma/plugin/tmp_restart.rb +36 -0
  69. data/lib/puma/plugin.rb +111 -0
  70. data/lib/puma/rack/builder.rb +297 -0
  71. data/lib/puma/rack/urlmap.rb +93 -0
  72. data/lib/puma/rack_default.rb +21 -4
  73. data/lib/puma/reactor.rb +102 -133
  74. data/lib/puma/request.rb +703 -0
  75. data/lib/puma/runner.rb +211 -0
  76. data/lib/puma/sd_notify.rb +146 -0
  77. data/lib/puma/server.rb +544 -436
  78. data/lib/puma/single.rb +72 -0
  79. data/lib/puma/state_file.rb +69 -0
  80. data/lib/puma/thread_pool.rb +282 -56
  81. data/lib/puma/util.rb +125 -0
  82. data/lib/puma.rb +80 -6
  83. data/lib/rack/handler/puma.rb +125 -47
  84. data/tools/Dockerfile +26 -0
  85. data/tools/trickletest.rb +44 -0
  86. metadata +77 -148
  87. data/COPYING +0 -55
  88. data/Gemfile +0 -10
  89. data/History.txt +0 -291
  90. data/Manifest.txt +0 -60
  91. data/Rakefile +0 -121
  92. data/TODO +0 -5
  93. data/docs/config.md +0 -0
  94. data/ext/puma_http11/ext_help.h +0 -15
  95. data/ext/puma_http11/io_buffer.c +0 -154
  96. data/lib/puma/accept_nonblock.rb +0 -23
  97. data/lib/puma/capistrano.rb +0 -34
  98. data/lib/puma/compat.rb +0 -11
  99. data/lib/puma/daemon_ext.rb +0 -20
  100. data/lib/puma/delegation.rb +0 -11
  101. data/lib/puma/java_io_buffer.rb +0 -45
  102. data/lib/puma/rack_patch.rb +0 -25
  103. data/puma.gemspec +0 -45
  104. data/test/test_app_status.rb +0 -88
  105. data/test/test_cli.rb +0 -171
  106. data/test/test_config.rb +0 -16
  107. data/test/test_http10.rb +0 -27
  108. data/test/test_http11.rb +0 -126
  109. data/test/test_integration.rb +0 -154
  110. data/test/test_iobuffer.rb +0 -38
  111. data/test/test_minissl.rb +0 -25
  112. data/test/test_null_io.rb +0 -31
  113. data/test/test_persistent.rb +0 -238
  114. data/test/test_puma_server.rb +0 -207
  115. data/test/test_rack_handler.rb +0 -10
  116. data/test/test_rack_server.rb +0 -141
  117. data/test/test_thread_pool.rb +0 -146
  118. data/test/test_unix_socket.rb +0 -39
  119. data/test/test_ws.rb +0 -89
  120. data/tools/jungle/init.d/README.md +0 -54
  121. data/tools/jungle/init.d/puma +0 -332
  122. data/tools/jungle/init.d/run-puma +0 -3
  123. data/tools/jungle/upstart/README.md +0 -61
  124. data/tools/jungle/upstart/puma-manager.conf +0 -31
  125. data/tools/jungle/upstart/puma.conf +0 -52
data/test/test_cli.rb DELETED
@@ -1,171 +0,0 @@
1
- require "rbconfig"
2
- require 'test/unit'
3
- require 'puma/cli'
4
- require 'tempfile'
5
-
6
- class TestCLI < Test::Unit::TestCase
7
- def setup
8
- @environment = 'production'
9
- @tmp_file = Tempfile.new("puma-test")
10
- @tmp_path = @tmp_file.path
11
- @tmp_file.close!
12
-
13
- @tmp_path2 = "#{@tmp_path}2"
14
-
15
- File.unlink @tmp_path if File.exist? @tmp_path
16
- File.unlink @tmp_path2 if File.exist? @tmp_path2
17
- end
18
-
19
- def teardown
20
- File.unlink @tmp_path if File.exist? @tmp_path
21
- File.unlink @tmp_path2 if File.exist? @tmp_path2
22
- end
23
-
24
- def test_pid_file
25
- cli = Puma::CLI.new ["--pidfile", @tmp_path]
26
- cli.parse_options
27
- cli.write_pid
28
-
29
- assert_equal File.read(@tmp_path).strip.to_i, Process.pid
30
-
31
- cli.stop
32
- assert !File.exist?(@tmp_path), "Pid file shouldn't exist anymore"
33
- end
34
-
35
- def test_control_for_tcp
36
- url = "tcp://127.0.0.1:9877/"
37
- sin = StringIO.new
38
- sout = StringIO.new
39
- cli = Puma::CLI.new ["-b", "tcp://127.0.0.1:9876",
40
- "--control", url,
41
- "--control-token", "",
42
- "test/lobster.ru"], sin, sout
43
- cli.parse_options
44
-
45
- thread_exception = nil
46
- t = Thread.new do
47
- begin
48
- cli.run
49
- rescue Exception => e
50
- thread_exception = e
51
- end
52
- end
53
-
54
- sleep 1
55
-
56
- s = TCPSocket.new "127.0.0.1", 9877
57
- s << "GET /stats HTTP/1.0\r\n\r\n"
58
- body = s.read
59
- assert_equal '{ "backlog": 0, "running": 0 }', body.split("\r\n").last
60
-
61
- cli.stop
62
- t.join
63
- assert_equal nil, thread_exception
64
- end
65
-
66
- unless defined?(JRUBY_VERSION) || RbConfig::CONFIG["host_os"] =~ /mingw|mswin/
67
- def test_control
68
- url = "unix://#{@tmp_path}"
69
-
70
- sin = StringIO.new
71
- sout = StringIO.new
72
-
73
- cli = Puma::CLI.new ["-b", "unix://#{@tmp_path2}",
74
- "--control", url,
75
- "--control-token", "",
76
- "test/lobster.ru"], sin, sout
77
- cli.parse_options
78
-
79
- t = Thread.new { cli.run }
80
-
81
- sleep 1
82
-
83
- s = UNIXSocket.new @tmp_path
84
- s << "GET /stats HTTP/1.0\r\n\r\n"
85
- body = s.read
86
-
87
- assert_equal '{ "backlog": 0, "running": 0 }', body.split("\r\n").last
88
-
89
- cli.stop
90
- t.join
91
- end
92
-
93
- def test_control_stop
94
- url = "unix://#{@tmp_path}"
95
-
96
- sin = StringIO.new
97
- sout = StringIO.new
98
-
99
- cli = Puma::CLI.new ["-b", "unix://#{@tmp_path2}",
100
- "--control", url,
101
- "--control-token", "",
102
- "test/lobster.ru"], sin, sout
103
- cli.parse_options
104
-
105
- t = Thread.new { cli.run }
106
-
107
- sleep 1
108
-
109
- s = UNIXSocket.new @tmp_path
110
- s << "GET /stop HTTP/1.0\r\n\r\n"
111
- body = s.read
112
-
113
- assert_equal '{ "status": "ok" }', body.split("\r\n").last
114
-
115
- t.join
116
- end
117
-
118
- def test_tmp_control
119
- url = "tcp://127.0.0.1:8232"
120
- cli = Puma::CLI.new ["--state", @tmp_path, "--control", "auto"]
121
- cli.parse_options
122
- cli.write_state
123
-
124
- data = YAML.load File.read(@tmp_path)
125
-
126
- assert_equal Process.pid, data["pid"]
127
-
128
- url = data["config"].options[:control_url]
129
-
130
- m = %r!unix://(.*)!.match(url)
131
-
132
- assert m, "'#{url}' is not a URL"
133
- end
134
- end # JRUBY or Windows
135
-
136
- def test_state
137
- url = "tcp://127.0.0.1:8232"
138
- cli = Puma::CLI.new ["--state", @tmp_path, "--control", url]
139
- cli.parse_options
140
- cli.write_state
141
-
142
- data = YAML.load File.read(@tmp_path)
143
-
144
- assert_equal Process.pid, data["pid"]
145
- assert_equal url, data["config"].options[:control_url]
146
- end
147
-
148
- def test_load_path
149
- cli = Puma::CLI.new ["--include", 'foo/bar']
150
- cli.parse_options
151
-
152
- assert_equal 'foo/bar', $LOAD_PATH[0]
153
- $LOAD_PATH.shift
154
-
155
- cli = Puma::CLI.new ["--include", 'foo/bar:baz/qux']
156
- cli.parse_options
157
-
158
- assert_equal 'foo/bar', $LOAD_PATH[0]
159
- $LOAD_PATH.shift
160
- assert_equal 'baz/qux', $LOAD_PATH[0]
161
- $LOAD_PATH.shift
162
- end
163
-
164
- def test_environment
165
- cli = Puma::CLI.new ["--environment", @environment]
166
- cli.parse_options
167
- cli.set_rack_environment
168
-
169
- assert_equal ENV['RACK_ENV'], @environment
170
- end
171
- end
data/test/test_config.rb DELETED
@@ -1,16 +0,0 @@
1
- require 'test/unit'
2
-
3
- require 'puma'
4
- require 'puma/configuration'
5
-
6
- class TestConfigFile < Test::Unit::TestCase
7
- def test_app_from_app_DSL
8
- opts = { :config_file => "test/config/app.rb" }
9
- conf = Puma::Configuration.new opts
10
- conf.load
11
-
12
- app = conf.app
13
-
14
- assert_equal [200, {}, ["embedded app"]], app.call({})
15
- end
16
- end
data/test/test_http10.rb DELETED
@@ -1,27 +0,0 @@
1
- require 'test/testhelp'
2
-
3
- class Http10ParserTest < Test::Unit::TestCase
4
- include Puma
5
-
6
- def test_parse_simple
7
- parser = HttpParser.new
8
- req = {}
9
- http = "GET / HTTP/1.0\r\n\r\n"
10
- nread = parser.execute(req, http, 0)
11
-
12
- assert nread == http.length, "Failed to parse the full HTTP request"
13
- assert parser.finished?, "Parser didn't finish"
14
- assert !parser.error?, "Parser had error"
15
- assert nread == parser.nread, "Number read returned from execute does not match"
16
-
17
- assert_equal '/', req['REQUEST_PATH']
18
- assert_equal 'HTTP/1.0', req['HTTP_VERSION']
19
- assert_equal '/', req['REQUEST_URI']
20
- assert_equal 'GET', req['REQUEST_METHOD']
21
- assert_nil req['FRAGMENT']
22
- assert_nil req['QUERY_STRING']
23
-
24
- parser.reset
25
- assert parser.nread == 0, "Number read after reset should be 0"
26
- end
27
- end
data/test/test_http11.rb DELETED
@@ -1,126 +0,0 @@
1
- # Copyright (c) 2011 Evan Phoenix
2
- # Copyright (c) 2005 Zed A. Shaw
3
-
4
- require 'test/testhelp'
5
-
6
- include Puma
7
-
8
- class Http11ParserTest < Test::Unit::TestCase
9
-
10
- def test_parse_simple
11
- parser = HttpParser.new
12
- req = {}
13
- http = "GET / HTTP/1.1\r\n\r\n"
14
- nread = parser.execute(req, http, 0)
15
-
16
- assert nread == http.length, "Failed to parse the full HTTP request"
17
- assert parser.finished?, "Parser didn't finish"
18
- assert !parser.error?, "Parser had error"
19
- assert nread == parser.nread, "Number read returned from execute does not match"
20
-
21
- assert_equal '/', req['REQUEST_PATH']
22
- assert_equal 'HTTP/1.1', req['HTTP_VERSION']
23
- assert_equal '/', req['REQUEST_URI']
24
- assert_equal 'GET', req['REQUEST_METHOD']
25
- assert_nil req['FRAGMENT']
26
- assert_nil req['QUERY_STRING']
27
-
28
- parser.reset
29
- assert parser.nread == 0, "Number read after reset should be 0"
30
- end
31
-
32
- def test_parse_dumbfuck_headers
33
- parser = HttpParser.new
34
- req = {}
35
- should_be_good = "GET / HTTP/1.1\r\naaaaaaaaaaaaa:++++++++++\r\n\r\n"
36
- nread = parser.execute(req, should_be_good, 0)
37
- assert_equal should_be_good.length, nread
38
- assert parser.finished?
39
- assert !parser.error?
40
- end
41
-
42
- def test_parse_error
43
- parser = HttpParser.new
44
- req = {}
45
- bad_http = "GET / SsUTF/1.1"
46
-
47
- error = false
48
- begin
49
- parser.execute(req, bad_http, 0)
50
- rescue
51
- error = true
52
- end
53
-
54
- assert error, "failed to throw exception"
55
- assert !parser.finished?, "Parser shouldn't be finished"
56
- assert parser.error?, "Parser SHOULD have error"
57
- end
58
-
59
- def test_fragment_in_uri
60
- parser = HttpParser.new
61
- req = {}
62
- get = "GET /forums/1/topics/2375?page=1#posts-17408 HTTP/1.1\r\n\r\n"
63
- assert_nothing_raised do
64
- parser.execute(req, get, 0)
65
- end
66
- assert parser.finished?
67
- assert_equal '/forums/1/topics/2375?page=1', req['REQUEST_URI']
68
- assert_equal 'posts-17408', req['FRAGMENT']
69
- end
70
-
71
- # lame random garbage maker
72
- def rand_data(min, max, readable=true)
73
- count = min + ((rand(max)+1) *10).to_i
74
- res = count.to_s + "/"
75
-
76
- if readable
77
- res << Digest::SHA1.hexdigest(rand(count * 100).to_s) * (count / 40)
78
- else
79
- res << Digest::SHA1.digest(rand(count * 100).to_s) * (count / 20)
80
- end
81
-
82
- return res
83
- end
84
-
85
-
86
- def test_horrible_queries
87
- parser = HttpParser.new
88
-
89
- # then that large header names are caught
90
- 10.times do |c|
91
- get = "GET /#{rand_data(10,120)} HTTP/1.1\r\nX-#{rand_data(1024, 1024+(c*1024))}: Test\r\n\r\n"
92
- assert_raises Puma::HttpParserError do
93
- parser.execute({}, get, 0)
94
- parser.reset
95
- end
96
- end
97
-
98
- # then that large mangled field values are caught
99
- 10.times do |c|
100
- get = "GET /#{rand_data(10,120)} HTTP/1.1\r\nX-Test: #{rand_data(1024, 1024+(c*1024), false)}\r\n\r\n"
101
- assert_raises Puma::HttpParserError do
102
- parser.execute({}, get, 0)
103
- parser.reset
104
- end
105
- end
106
-
107
- # then large headers are rejected too
108
- get = "GET /#{rand_data(10,120)} HTTP/1.1\r\n"
109
- get << "X-Test: test\r\n" * (80 * 1024)
110
- assert_raises Puma::HttpParserError do
111
- parser.execute({}, get, 0)
112
- parser.reset
113
- end
114
-
115
- # finally just that random garbage gets blocked all the time
116
- 10.times do |c|
117
- get = "GET #{rand_data(1024, 1024+(c*1024), false)} #{rand_data(1024, 1024+(c*1024), false)}\r\n\r\n"
118
- assert_raises Puma::HttpParserError do
119
- parser.execute({}, get, 0)
120
- parser.reset
121
- end
122
- end
123
-
124
- end
125
- end
126
-
@@ -1,154 +0,0 @@
1
- require "rbconfig"
2
- require 'test/unit'
3
- require 'socket'
4
- require 'timeout'
5
- require 'net/http'
6
- require 'tempfile'
7
-
8
- require 'puma/cli'
9
- require 'puma/control_cli'
10
-
11
- # These don't run on travis because they're too fragile
12
-
13
- class TestIntegration < Test::Unit::TestCase
14
- def setup
15
- @state_path = "test/test_puma.state"
16
- @bind_path = "test/test_server.sock"
17
- @control_path = "test/test_control.sock"
18
- @tcp_port = 9998
19
-
20
- @server = nil
21
- @script = nil
22
- end
23
-
24
- def teardown
25
- File.unlink @state_path rescue nil
26
- File.unlink @bind_path rescue nil
27
- File.unlink @control_path rescue nil
28
-
29
- if @server
30
- Process.kill "INT", @server.pid
31
- begin
32
- Process.wait @server.pid
33
- rescue Errno::ECHILD
34
- end
35
-
36
- @server.close
37
- end
38
-
39
- if @script
40
- @script.close!
41
- end
42
- end
43
-
44
- def server(opts)
45
- core = "#{Gem.ruby} -rubygems -Ilib bin/puma"
46
- cmd = "#{core} --restart-cmd '#{core}' -b tcp://127.0.0.1:#{@tcp_port} #{opts}"
47
- tf = Tempfile.new "puma-test"
48
- tf.puts "exec #{cmd}"
49
- tf.close
50
-
51
- @script = tf
52
-
53
- @server = IO.popen("sh #{tf.path}", "r")
54
-
55
- true while @server.gets =~ /Ctrl-C/
56
-
57
- sleep 1
58
-
59
- @server
60
- end
61
-
62
- def signal(which)
63
- Process.kill which, @server.pid
64
- end
65
-
66
- def test_stop_via_pumactl
67
- if defined?(JRUBY_VERSION) || RbConfig::CONFIG["host_os"] =~ /mingw|mswin/
68
- assert true
69
- return
70
- end
71
-
72
- sin = StringIO.new
73
- sout = StringIO.new
74
-
75
- cli = Puma::CLI.new %W!-q -S #{@state_path} -b unix://#{@bind_path} --control unix://#{@control_path} test/hello.ru!, sin, sout
76
-
77
- t = Thread.new do
78
- cli.run
79
- end
80
-
81
- sleep 1
82
-
83
- s = UNIXSocket.new @bind_path
84
- s << "GET / HTTP/1.0\r\n\r\n"
85
- assert_equal "Hello World", s.read.split("\r\n").last
86
-
87
- ccli = Puma::ControlCLI.new %W!-S #{@state_path} stop!, sout
88
-
89
- ccli.run
90
-
91
- assert_kind_of Thread, t.join(1), "server didn't stop"
92
- end
93
-
94
- def notest_restart_closes_keepalive_sockets
95
- server("-q test/hello.ru")
96
-
97
- s = TCPSocket.new "localhost", @tcp_port
98
- s << "GET / HTTP/1.1\r\n\r\n"
99
- true until s.gets == "\r\n"
100
-
101
- s.readpartial(20)
102
- signal :USR2
103
-
104
- true while @server.gets =~ /Ctrl-C/
105
- sleep 1
106
-
107
- s.write "GET / HTTP/1.1\r\n\r\n"
108
-
109
- assert_raises Errno::ECONNRESET do
110
- Timeout.timeout(2) do
111
- raise Errno::ECONNRESET unless s.read(2)
112
- end
113
- end
114
-
115
- s = TCPSocket.new "localhost", @tcp_port
116
- s << "GET / HTTP/1.0\r\n\r\n"
117
- assert_equal "Hello World", s.read.split("\r\n").last
118
- end
119
-
120
- def notest_restart_closes_keepalive_sockets_workers
121
- server("-q -w 2 test/hello.ru")
122
-
123
- s = TCPSocket.new "localhost", @tcp_port
124
- s << "GET / HTTP/1.1\r\n\r\n"
125
- true until s.gets == "\r\n"
126
-
127
- s.readpartial(20)
128
- signal :USR2
129
-
130
- true while @server.gets =~ /Ctrl-C/
131
- sleep 1
132
-
133
- s.write "GET / HTTP/1.1\r\n\r\n"
134
-
135
- assert_raises Errno::ECONNRESET do
136
- Timeout.timeout(2) do
137
- raise Errno::ECONNRESET unless s.read(2)
138
- end
139
- end
140
-
141
- s = TCPSocket.new "localhost", @tcp_port
142
- s << "GET / HTTP/1.0\r\n\r\n"
143
- assert_equal "Hello World", s.read.split("\r\n").last
144
- end
145
-
146
- def test_bad_query_string_outputs_400
147
- server "-q test/hello.ru 2>&1"
148
-
149
- s = TCPSocket.new "localhost", @tcp_port
150
- s << "GET /?h=% HTTP/1.0\r\n\r\n"
151
- data = s.read
152
- assert_equal "HTTP/1.1 400 Bad Request\r\n\r\n", data
153
- end
154
- end unless ENV['TRAVIS']
@@ -1,38 +0,0 @@
1
- require 'puma/io_buffer'
2
- require 'test/unit'
3
-
4
- class TestIOBuffer < Test::Unit::TestCase
5
- attr_accessor :iobuf
6
- def setup
7
- self.iobuf = Puma::IOBuffer.new
8
- end
9
-
10
- def test_initial_size
11
- assert_equal 0, iobuf.used
12
- assert iobuf.capacity > 0
13
- end
14
-
15
- def test_append_op
16
- iobuf << "abc"
17
- assert_equal "abc", iobuf.to_s
18
- iobuf << "123"
19
- assert_equal "abc123", iobuf.to_s
20
- assert_equal 6, iobuf.used
21
- end
22
-
23
- def test_append
24
- expected = "mary had a little lamb"
25
- iobuf.append("mary", " ", "had ", "a little", " lamb")
26
- assert_equal expected, iobuf.to_s
27
- assert_equal expected.length, iobuf.used
28
- end
29
-
30
- def test_reset
31
- iobuf << "content"
32
- assert_equal "content", iobuf.to_s
33
- iobuf.reset
34
- assert_equal 0, iobuf.used
35
- assert_equal "", iobuf.to_s
36
- end
37
-
38
- end
data/test/test_minissl.rb DELETED
@@ -1,25 +0,0 @@
1
- require 'test/unit'
2
-
3
- unless defined? JRUBY_VERSION
4
-
5
- require 'puma'
6
- require 'puma/minissl'
7
-
8
- class TestMiniSSL < Test::Unit::TestCase
9
-
10
- def test_raises_with_invalid_key_file
11
- ctx = Puma::MiniSSL::Context.new
12
-
13
- exception = assert_raise(ArgumentError) { ctx.key = "/no/such/key" }
14
- assert_equal("No such key file '/no/such/key'", exception.message)
15
- end
16
-
17
- def test_raises_with_invalid_cert_file
18
- ctx = Puma::MiniSSL::Context.new
19
-
20
- exception = assert_raise(ArgumentError) { ctx.cert = "/no/such/cert" }
21
- assert_equal("No such cert file '/no/such/cert'", exception.message)
22
- end
23
- end
24
-
25
- end
data/test/test_null_io.rb DELETED
@@ -1,31 +0,0 @@
1
- require 'puma/null_io'
2
- require 'test/unit'
3
-
4
- class TestNullIO < Test::Unit::TestCase
5
- attr_accessor :nio
6
- def setup
7
- self.nio = Puma::NullIO.new
8
- end
9
-
10
- def test_read_with_no_arguments
11
- assert_equal "", nio.read
12
- end
13
-
14
- def test_read_with_nil_length
15
- assert_equal "", nio.read(nil)
16
- end
17
-
18
- def test_read_with_zero_length
19
- assert_equal "", nio.read(0)
20
- end
21
-
22
- def test_read_with_positive_integer_length
23
- assert_nil nio.read(1)
24
- end
25
-
26
- def test_read_with_length_and_buffer
27
- buf = ""
28
- assert_nil nio.read(1,buf)
29
- assert_equal "", buf
30
- end
31
- end