rack 2.0.9.3 → 2.1.4.3

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of rack might be problematic. Click here for more details.

Files changed (189) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +92 -0
  3. data/{COPYING → MIT-LICENSE} +4 -2
  4. data/README.rdoc +76 -116
  5. data/Rakefile +25 -18
  6. data/SPEC +9 -9
  7. data/bin/rackup +1 -0
  8. data/example/lobster.ru +2 -0
  9. data/example/protectedlobster.rb +3 -1
  10. data/example/protectedlobster.ru +2 -0
  11. data/lib/rack/auth/abstract/handler.rb +3 -1
  12. data/lib/rack/auth/abstract/request.rb +2 -0
  13. data/lib/rack/auth/basic.rb +4 -1
  14. data/lib/rack/auth/digest/md5.rb +9 -7
  15. data/lib/rack/auth/digest/nonce.rb +6 -3
  16. data/lib/rack/auth/digest/params.rb +4 -2
  17. data/lib/rack/auth/digest/request.rb +2 -0
  18. data/lib/rack/body_proxy.rb +3 -6
  19. data/lib/rack/builder.rb +39 -15
  20. data/lib/rack/cascade.rb +6 -5
  21. data/lib/rack/chunked.rb +29 -6
  22. data/lib/rack/common_logger.rb +9 -8
  23. data/lib/rack/conditional_get.rb +3 -1
  24. data/lib/rack/config.rb +2 -0
  25. data/lib/rack/content_length.rb +3 -1
  26. data/lib/rack/content_type.rb +3 -1
  27. data/lib/rack/core_ext/regexp.rb +14 -0
  28. data/lib/rack/deflater.rb +32 -17
  29. data/lib/rack/directory.rb +19 -16
  30. data/lib/rack/etag.rb +3 -1
  31. data/lib/rack/events.rb +5 -3
  32. data/lib/rack/file.rb +4 -173
  33. data/lib/rack/files.rb +178 -0
  34. data/lib/rack/handler/cgi.rb +3 -1
  35. data/lib/rack/handler/fastcgi.rb +4 -2
  36. data/lib/rack/handler/lsws.rb +3 -1
  37. data/lib/rack/handler/scgi.rb +9 -6
  38. data/lib/rack/handler/thin.rb +3 -1
  39. data/lib/rack/handler/webrick.rb +4 -2
  40. data/lib/rack/handler.rb +7 -2
  41. data/lib/rack/head.rb +2 -0
  42. data/lib/rack/lint.rb +14 -11
  43. data/lib/rack/lobster.rb +7 -5
  44. data/lib/rack/lock.rb +2 -0
  45. data/lib/rack/logger.rb +2 -0
  46. data/lib/rack/media_type.rb +10 -5
  47. data/lib/rack/method_override.rb +4 -2
  48. data/lib/rack/mime.rb +9 -1
  49. data/lib/rack/mock.rb +74 -15
  50. data/lib/rack/multipart/generator.rb +6 -7
  51. data/lib/rack/multipart/parser.rb +50 -45
  52. data/lib/rack/multipart/uploaded_file.rb +2 -0
  53. data/lib/rack/multipart.rb +3 -1
  54. data/lib/rack/null_logger.rb +2 -0
  55. data/lib/rack/query_parser.rb +51 -25
  56. data/lib/rack/recursive.rb +7 -5
  57. data/lib/rack/reloader.rb +10 -4
  58. data/lib/rack/request.rb +79 -26
  59. data/lib/rack/response.rb +71 -31
  60. data/lib/rack/rewindable_input.rb +4 -2
  61. data/lib/rack/runtime.rb +4 -2
  62. data/lib/rack/sendfile.rb +15 -8
  63. data/lib/rack/server.rb +88 -18
  64. data/lib/rack/session/abstract/id.rb +30 -20
  65. data/lib/rack/session/cookie.rb +10 -9
  66. data/lib/rack/session/memcache.rb +4 -93
  67. data/lib/rack/session/pool.rb +4 -2
  68. data/lib/rack/show_exceptions.rb +15 -9
  69. data/lib/rack/show_status.rb +4 -2
  70. data/lib/rack/static.rb +15 -10
  71. data/lib/rack/tempfile_reaper.rb +2 -0
  72. data/lib/rack/urlmap.rb +11 -2
  73. data/lib/rack/utils.rb +58 -71
  74. data/lib/rack.rb +63 -60
  75. data/rack.gemspec +17 -7
  76. metadata +28 -170
  77. data/HISTORY.md +0 -520
  78. data/test/builder/an_underscore_app.rb +0 -5
  79. data/test/builder/anything.rb +0 -5
  80. data/test/builder/comment.ru +0 -4
  81. data/test/builder/end.ru +0 -5
  82. data/test/builder/line.ru +0 -1
  83. data/test/builder/options.ru +0 -2
  84. data/test/cgi/assets/folder/test.js +0 -1
  85. data/test/cgi/assets/fonts/font.eot +0 -1
  86. data/test/cgi/assets/images/image.png +0 -1
  87. data/test/cgi/assets/index.html +0 -1
  88. data/test/cgi/assets/javascripts/app.js +0 -1
  89. data/test/cgi/assets/stylesheets/app.css +0 -1
  90. data/test/cgi/lighttpd.conf +0 -26
  91. data/test/cgi/rackup_stub.rb +0 -6
  92. data/test/cgi/sample_rackup.ru +0 -5
  93. data/test/cgi/test +0 -9
  94. data/test/cgi/test+directory/test+file +0 -1
  95. data/test/cgi/test.fcgi +0 -9
  96. data/test/cgi/test.gz +0 -0
  97. data/test/cgi/test.ru +0 -5
  98. data/test/gemloader.rb +0 -10
  99. data/test/helper.rb +0 -34
  100. data/test/multipart/bad_robots +0 -259
  101. data/test/multipart/binary +0 -0
  102. data/test/multipart/content_type_and_no_filename +0 -6
  103. data/test/multipart/empty +0 -10
  104. data/test/multipart/fail_16384_nofile +0 -814
  105. data/test/multipart/file1.txt +0 -1
  106. data/test/multipart/filename_and_modification_param +0 -7
  107. data/test/multipart/filename_and_no_name +0 -6
  108. data/test/multipart/filename_with_encoded_words +0 -7
  109. data/test/multipart/filename_with_escaped_quotes +0 -6
  110. data/test/multipart/filename_with_escaped_quotes_and_modification_param +0 -7
  111. data/test/multipart/filename_with_null_byte +0 -7
  112. data/test/multipart/filename_with_percent_escaped_quotes +0 -6
  113. data/test/multipart/filename_with_single_quote +0 -7
  114. data/test/multipart/filename_with_unescaped_percentages +0 -6
  115. data/test/multipart/filename_with_unescaped_percentages2 +0 -6
  116. data/test/multipart/filename_with_unescaped_percentages3 +0 -6
  117. data/test/multipart/filename_with_unescaped_quotes +0 -6
  118. data/test/multipart/ie +0 -6
  119. data/test/multipart/invalid_character +0 -6
  120. data/test/multipart/mixed_files +0 -21
  121. data/test/multipart/nested +0 -10
  122. data/test/multipart/none +0 -9
  123. data/test/multipart/quoted +0 -15
  124. data/test/multipart/rack-logo.png +0 -0
  125. data/test/multipart/semicolon +0 -6
  126. data/test/multipart/text +0 -15
  127. data/test/multipart/three_files_three_fields +0 -31
  128. data/test/multipart/unity3d_wwwform +0 -11
  129. data/test/multipart/webkit +0 -32
  130. data/test/rackup/config.ru +0 -31
  131. data/test/registering_handler/rack/handler/registering_myself.rb +0 -8
  132. data/test/spec_auth_basic.rb +0 -89
  133. data/test/spec_auth_digest.rb +0 -260
  134. data/test/spec_body_proxy.rb +0 -85
  135. data/test/spec_builder.rb +0 -233
  136. data/test/spec_cascade.rb +0 -63
  137. data/test/spec_cgi.rb +0 -84
  138. data/test/spec_chunked.rb +0 -103
  139. data/test/spec_common_logger.rb +0 -107
  140. data/test/spec_conditional_get.rb +0 -103
  141. data/test/spec_config.rb +0 -23
  142. data/test/spec_content_length.rb +0 -86
  143. data/test/spec_content_type.rb +0 -46
  144. data/test/spec_deflater.rb +0 -375
  145. data/test/spec_directory.rb +0 -148
  146. data/test/spec_etag.rb +0 -108
  147. data/test/spec_events.rb +0 -133
  148. data/test/spec_fastcgi.rb +0 -85
  149. data/test/spec_file.rb +0 -264
  150. data/test/spec_handler.rb +0 -57
  151. data/test/spec_head.rb +0 -46
  152. data/test/spec_lint.rb +0 -520
  153. data/test/spec_lobster.rb +0 -59
  154. data/test/spec_lock.rb +0 -204
  155. data/test/spec_logger.rb +0 -24
  156. data/test/spec_media_type.rb +0 -42
  157. data/test/spec_method_override.rb +0 -110
  158. data/test/spec_mime.rb +0 -51
  159. data/test/spec_mock.rb +0 -359
  160. data/test/spec_multipart.rb +0 -721
  161. data/test/spec_null_logger.rb +0 -21
  162. data/test/spec_recursive.rb +0 -75
  163. data/test/spec_request.rb +0 -1423
  164. data/test/spec_response.rb +0 -528
  165. data/test/spec_rewindable_input.rb +0 -128
  166. data/test/spec_runtime.rb +0 -50
  167. data/test/spec_sendfile.rb +0 -125
  168. data/test/spec_server.rb +0 -193
  169. data/test/spec_session_abstract_id.rb +0 -31
  170. data/test/spec_session_abstract_session_hash.rb +0 -45
  171. data/test/spec_session_cookie.rb +0 -442
  172. data/test/spec_session_memcache.rb +0 -357
  173. data/test/spec_session_persisted_secure_secure_session_hash.rb +0 -73
  174. data/test/spec_session_pool.rb +0 -247
  175. data/test/spec_show_exceptions.rb +0 -93
  176. data/test/spec_show_status.rb +0 -104
  177. data/test/spec_static.rb +0 -184
  178. data/test/spec_tempfile_reaper.rb +0 -64
  179. data/test/spec_thin.rb +0 -96
  180. data/test/spec_urlmap.rb +0 -237
  181. data/test/spec_utils.rb +0 -742
  182. data/test/spec_version.rb +0 -11
  183. data/test/spec_webrick.rb +0 -206
  184. data/test/static/another/index.html +0 -1
  185. data/test/static/foo.html +0 -1
  186. data/test/static/index.html +0 -1
  187. data/test/testrequest.rb +0 -78
  188. data/test/unregistered_handler/rack/handler/unregistered.rb +0 -7
  189. data/test/unregistered_handler/rack/handler/unregistered_long_one.rb +0 -7
@@ -1,125 +0,0 @@
1
- require 'minitest/autorun'
2
- require 'fileutils'
3
- require 'rack/lint'
4
- require 'rack/sendfile'
5
- require 'rack/mock'
6
- require 'tmpdir'
7
-
8
- describe Rack::Sendfile do
9
- def sendfile_body
10
- FileUtils.touch File.join(Dir.tmpdir, "rack_sendfile")
11
- res = ['Hello World']
12
- def res.to_path ; File.join(Dir.tmpdir, "rack_sendfile") ; end
13
- res
14
- end
15
-
16
- def simple_app(body=sendfile_body)
17
- lambda { |env| [200, {'Content-Type' => 'text/plain'}, body] }
18
- end
19
-
20
- def sendfile_app(body, mappings = [])
21
- Rack::Lint.new Rack::Sendfile.new(simple_app(body), nil, mappings)
22
- end
23
-
24
- def request(headers={}, body=sendfile_body, mappings=[])
25
- yield Rack::MockRequest.new(sendfile_app(body, mappings)).get('/', headers)
26
- end
27
-
28
- def open_file(path)
29
- Class.new(File) do
30
- unless method_defined?(:to_path)
31
- alias :to_path :path
32
- end
33
- end.open(path, 'wb+')
34
- end
35
-
36
- it "does nothing when no X-Sendfile-Type header present" do
37
- request do |response|
38
- response.must_be :ok?
39
- response.body.must_equal 'Hello World'
40
- response.headers.wont_include 'X-Sendfile'
41
- end
42
- end
43
-
44
- it "sets X-Sendfile response header and discards body" do
45
- request 'HTTP_X_SENDFILE_TYPE' => 'X-Sendfile' do |response|
46
- response.must_be :ok?
47
- response.body.must_be :empty?
48
- response.headers['Content-Length'].must_equal '0'
49
- response.headers['X-Sendfile'].must_equal File.join(Dir.tmpdir, "rack_sendfile")
50
- end
51
- end
52
-
53
- it "sets X-Lighttpd-Send-File response header and discards body" do
54
- request 'HTTP_X_SENDFILE_TYPE' => 'X-Lighttpd-Send-File' do |response|
55
- response.must_be :ok?
56
- response.body.must_be :empty?
57
- response.headers['Content-Length'].must_equal '0'
58
- response.headers['X-Lighttpd-Send-File'].must_equal File.join(Dir.tmpdir, "rack_sendfile")
59
- end
60
- end
61
-
62
- it "sets X-Accel-Redirect response header and discards body" do
63
- headers = {
64
- 'HTTP_X_SENDFILE_TYPE' => 'X-Accel-Redirect',
65
- 'HTTP_X_ACCEL_MAPPING' => "#{Dir.tmpdir}/=/foo/bar/"
66
- }
67
- request headers do |response|
68
- response.must_be :ok?
69
- response.body.must_be :empty?
70
- response.headers['Content-Length'].must_equal '0'
71
- response.headers['X-Accel-Redirect'].must_equal '/foo/bar/rack_sendfile'
72
- end
73
- end
74
-
75
- it 'writes to rack.error when no X-Accel-Mapping is specified' do
76
- request 'HTTP_X_SENDFILE_TYPE' => 'X-Accel-Redirect' do |response|
77
- response.must_be :ok?
78
- response.body.must_equal 'Hello World'
79
- response.headers.wont_include 'X-Accel-Redirect'
80
- response.errors.must_include 'X-Accel-Mapping'
81
- end
82
- end
83
-
84
- it 'does nothing when body does not respond to #to_path' do
85
- request({'HTTP_X_SENDFILE_TYPE' => 'X-Sendfile'}, ['Not a file...']) do |response|
86
- response.body.must_equal 'Not a file...'
87
- response.headers.wont_include 'X-Sendfile'
88
- end
89
- end
90
-
91
- it "sets X-Accel-Redirect response header and discards body when initialized with multiple mappings" do
92
- begin
93
- dir1 = Dir.mktmpdir
94
- dir2 = Dir.mktmpdir
95
-
96
- first_body = open_file(File.join(dir1, 'rack_sendfile'))
97
- first_body.puts 'hello world'
98
-
99
- second_body = open_file(File.join(dir2, 'rack_sendfile'))
100
- second_body.puts 'goodbye world'
101
-
102
- mappings = [
103
- ["#{dir1}/", '/foo/bar/'],
104
- ["#{dir2}/", '/wibble/']
105
- ]
106
-
107
- request({'HTTP_X_SENDFILE_TYPE' => 'X-Accel-Redirect'}, first_body, mappings) do |response|
108
- response.must_be :ok?
109
- response.body.must_be :empty?
110
- response.headers['Content-Length'].must_equal '0'
111
- response.headers['X-Accel-Redirect'].must_equal '/foo/bar/rack_sendfile'
112
- end
113
-
114
- request({'HTTP_X_SENDFILE_TYPE' => 'X-Accel-Redirect'}, second_body, mappings) do |response|
115
- response.must_be :ok?
116
- response.body.must_be :empty?
117
- response.headers['Content-Length'].must_equal '0'
118
- response.headers['X-Accel-Redirect'].must_equal '/wibble/rack_sendfile'
119
- end
120
- ensure
121
- FileUtils.remove_entry_secure dir1
122
- FileUtils.remove_entry_secure dir2
123
- end
124
- end
125
- end
data/test/spec_server.rb DELETED
@@ -1,193 +0,0 @@
1
- require 'minitest/autorun'
2
- require 'rack'
3
- require 'rack/server'
4
- require 'tempfile'
5
- require 'socket'
6
- require 'open-uri'
7
-
8
- module Minitest::Spec::DSL
9
- alias :should :it
10
- end
11
-
12
- describe Rack::Server do
13
- SPEC_ARGV = []
14
-
15
- before { SPEC_ARGV[0..-1] = [] }
16
-
17
- def app
18
- lambda { |env| [200, {'Content-Type' => 'text/plain'}, ['success']] }
19
- end
20
-
21
- def with_stderr
22
- old, $stderr = $stderr, StringIO.new
23
- yield $stderr
24
- ensure
25
- $stderr = old
26
- end
27
-
28
- it "overrides :config if :app is passed in" do
29
- server = Rack::Server.new(:app => "FOO")
30
- server.app.must_equal "FOO"
31
- end
32
-
33
- it "prefer to use :builder when it is passed in" do
34
- server = Rack::Server.new(:builder => "run lambda { |env| [200, {'Content-Type' => 'text/plain'}, ['success']] }")
35
- server.app.class.must_equal Proc
36
- Rack::MockRequest.new(server.app).get("/").body.to_s.must_equal 'success'
37
- end
38
-
39
- it "allow subclasses to override middleware" do
40
- server = Class.new(Rack::Server).class_eval { def middleware; Hash.new [] end; self }
41
- server.middleware['deployment'].wont_equal []
42
- server.new(:app => 'foo').middleware['deployment'].must_equal []
43
- end
44
-
45
- it "allow subclasses to override default middleware" do
46
- server = Class.new(Rack::Server).instance_eval { def default_middleware_by_environment; Hash.new [] end; self }
47
- server.middleware['deployment'].must_equal []
48
- server.new(:app => 'foo').middleware['deployment'].must_equal []
49
- end
50
-
51
- it "only provide default middleware for development and deployment environments" do
52
- Rack::Server.default_middleware_by_environment.keys.sort.must_equal %w(deployment development)
53
- end
54
-
55
- it "always return an empty array for unknown environments" do
56
- server = Rack::Server.new(:app => 'foo')
57
- server.middleware['production'].must_equal []
58
- end
59
-
60
- it "not include Rack::Lint in deployment environment" do
61
- server = Rack::Server.new(:app => 'foo')
62
- server.middleware['deployment'].flatten.wont_include Rack::Lint
63
- end
64
-
65
- it "not include Rack::ShowExceptions in deployment environment" do
66
- server = Rack::Server.new(:app => 'foo')
67
- server.middleware['deployment'].flatten.wont_include Rack::ShowExceptions
68
- end
69
-
70
- it "include Rack::TempfileReaper in deployment environment" do
71
- server = Rack::Server.new(:app => 'foo')
72
- server.middleware['deployment'].flatten.must_include Rack::TempfileReaper
73
- end
74
-
75
- it "support CGI" do
76
- begin
77
- o, ENV["REQUEST_METHOD"] = ENV["REQUEST_METHOD"], 'foo'
78
- server = Rack::Server.new(:app => 'foo')
79
- server.server.name =~ /CGI/
80
- Rack::Server.logging_middleware.call(server).must_be_nil
81
- ensure
82
- ENV['REQUEST_METHOD'] = o
83
- end
84
- end
85
-
86
- it "be quiet if said so" do
87
- server = Rack::Server.new(:app => "FOO", :quiet => true)
88
- Rack::Server.logging_middleware.call(server).must_be_nil
89
- end
90
-
91
- it "use a full path to the pidfile" do
92
- # avoids issues with daemonize chdir
93
- opts = Rack::Server.new.send(:parse_options, %w[--pid testing.pid])
94
- opts[:pid].must_equal ::File.expand_path('testing.pid')
95
- end
96
-
97
- it "get options from ARGV" do
98
- SPEC_ARGV[0..-1] = ['--debug', '-sthin', '--env', 'production']
99
- server = Rack::Server.new
100
- server.options[:debug].must_equal true
101
- server.options[:server].must_equal 'thin'
102
- server.options[:environment].must_equal 'production'
103
- end
104
-
105
- it "only override non-passed options from parsed .ru file" do
106
- builder_file = File.join(File.dirname(__FILE__), 'builder', 'options.ru')
107
- SPEC_ARGV[0..-1] = ['--debug', '-sthin', '--env', 'production', builder_file]
108
- server = Rack::Server.new
109
- server.app # force .ru file to be parsed
110
-
111
- server.options[:debug].must_equal true
112
- server.options[:server].must_equal 'thin'
113
- server.options[:environment].must_equal 'production'
114
- server.options[:Port].must_equal '2929'
115
- end
116
-
117
- it "run a server" do
118
- pidfile = Tempfile.open('pidfile') { |f| break f }
119
- FileUtils.rm pidfile.path
120
- server = Rack::Server.new(
121
- :app => app,
122
- :environment => 'none',
123
- :pid => pidfile.path,
124
- :Port => TCPServer.open('127.0.0.1', 0){|s| s.addr[1] },
125
- :Host => '127.0.0.1',
126
- :Logger => WEBrick::Log.new(nil, WEBrick::BasicLog::WARN),
127
- :AccessLog => [],
128
- :daemonize => false,
129
- :server => 'webrick'
130
- )
131
- t = Thread.new { server.start { |s| Thread.current[:server] = s } }
132
- t.join(0.01) until t[:server] && t[:server].status != :Stop
133
- body = open("http://127.0.0.1:#{server.options[:Port]}/") { |f| f.read }
134
- body.must_equal 'success'
135
-
136
- Process.kill(:INT, $$)
137
- t.join
138
- open(pidfile.path) { |f| f.read.must_equal $$.to_s }
139
- end
140
-
141
- it "check pid file presence and running process" do
142
- pidfile = Tempfile.open('pidfile') { |f| f.write($$); break f }.path
143
- server = Rack::Server.new(:pid => pidfile)
144
- server.send(:pidfile_process_status).must_equal :running
145
- end
146
-
147
- it "check pid file presence and dead process" do
148
- dead_pid = `echo $$`.to_i
149
- pidfile = Tempfile.open('pidfile') { |f| f.write(dead_pid); break f }.path
150
- server = Rack::Server.new(:pid => pidfile)
151
- server.send(:pidfile_process_status).must_equal :dead
152
- end
153
-
154
- it "check pid file presence and exited process" do
155
- pidfile = Tempfile.open('pidfile') { |f| break f }.path
156
- ::File.delete(pidfile)
157
- server = Rack::Server.new(:pid => pidfile)
158
- server.send(:pidfile_process_status).must_equal :exited
159
- end
160
-
161
- it "check pid file presence and not owned process" do
162
- pidfile = Tempfile.open('pidfile') { |f| f.write(1); break f }.path
163
- server = Rack::Server.new(:pid => pidfile)
164
- server.send(:pidfile_process_status).must_equal :not_owned
165
- end
166
-
167
- it "not write pid file when it is created after check" do
168
- pidfile = Tempfile.open('pidfile') { |f| break f }.path
169
- ::File.delete(pidfile)
170
- server = Rack::Server.new(:pid => pidfile)
171
- ::File.open(pidfile, 'w') { |f| f.write(1) }
172
- with_stderr do |err|
173
- lambda { server.send(:write_pid) }.must_raise SystemExit
174
- err.rewind
175
- output = err.read
176
- output.must_match(/already running/)
177
- output.must_include pidfile
178
- end
179
- end
180
-
181
- it "inform the user about existing pidfiles with running processes" do
182
- pidfile = Tempfile.open('pidfile') { |f| f.write(1); break f }.path
183
- server = Rack::Server.new(:pid => pidfile)
184
- with_stderr do |err|
185
- lambda { server.start }.must_raise SystemExit
186
- err.rewind
187
- output = err.read
188
- output.must_match(/already running/)
189
- output.must_include pidfile
190
- end
191
- end
192
-
193
- end
@@ -1,31 +0,0 @@
1
- require 'minitest/autorun'
2
- ### WARNING: there be hax in this file.
3
-
4
- require 'rack/session/abstract/id'
5
-
6
- describe Rack::Session::Abstract::ID do
7
- attr_reader :id
8
-
9
- def setup
10
- super
11
- @id = Rack::Session::Abstract::ID
12
- end
13
-
14
- it "use securerandom" do
15
- assert_equal ::SecureRandom, id::DEFAULT_OPTIONS[:secure_random]
16
-
17
- id = @id.new nil
18
- assert_equal ::SecureRandom, id.sid_secure
19
- end
20
-
21
- it "allow to use another securerandom provider" do
22
- secure_random = Class.new do
23
- def hex(*args)
24
- 'fake_hex'
25
- end
26
- end
27
- id = Rack::Session::Abstract::ID.new nil, :secure_random => secure_random.new
28
- id.send(:generate_sid).must_equal 'fake_hex'
29
- end
30
-
31
- end
@@ -1,45 +0,0 @@
1
- require 'minitest/autorun'
2
- require 'rack/session/abstract/id'
3
-
4
- describe Rack::Session::Abstract::SessionHash do
5
- attr_reader :hash
6
-
7
- def setup
8
- super
9
- store = Class.new do
10
- def load_session(req)
11
- ["id", {foo: :bar, baz: :qux}]
12
- end
13
- def session_exists?(req)
14
- true
15
- end
16
- end
17
- @hash = Rack::Session::Abstract::SessionHash.new(store.new, nil)
18
- end
19
-
20
- it "returns keys" do
21
- assert_equal ["foo", "baz"], hash.keys
22
- end
23
-
24
- it "returns values" do
25
- assert_equal [:bar, :qux], hash.values
26
- end
27
-
28
- describe "#fetch" do
29
- it "returns value for a matching key" do
30
- assert_equal :bar, hash.fetch(:foo)
31
- end
32
-
33
- it "works with a default value" do
34
- assert_equal :default, hash.fetch(:unknown, :default)
35
- end
36
-
37
- it "works with a block" do
38
- assert_equal :default, hash.fetch(:unkown) { :default }
39
- end
40
-
41
- it "it raises when fetching unknown keys without defaults" do
42
- lambda { hash.fetch(:unknown) }.must_raise KeyError
43
- end
44
- end
45
- end