diff options
Diffstat (limited to 'test/spec_session_pool.rb')
-rw-r--r-- | test/spec_session_pool.rb | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/test/spec_session_pool.rb b/test/spec_session_pool.rb index 5eaadfff..fda5f56e 100644 --- a/test/spec_session_pool.rb +++ b/test/spec_session_pool.rb @@ -1,4 +1,6 @@ -require 'minitest/autorun' +# frozen_string_literal: true + +require 'minitest/global_expectations/autorun' require 'thread' require 'rack/lint' require 'rack/mock' @@ -138,7 +140,7 @@ describe Rack::Session::Pool do dreq = Rack::MockRequest.new(defer) res1 = dreq.get("/") - res1["Set-Cookie"].must_equal nil + res1["Set-Cookie"].must_be_nil res1.body.must_equal '{"counter"=>1}' pool.pool.size.must_equal 1 end @@ -157,18 +159,18 @@ describe Rack::Session::Pool do res = req.get('/') res.body.must_equal '{"counter"=>1}' cookie = res["Set-Cookie"] - sess_id = cookie[/#{pool.key}=([^,;]+)/,1] + sess_id = cookie[/#{pool.key}=([^,;]+)/, 1] delta_incrementor = lambda do |env| # emulate disconjoinment of threading env['rack.session'] = env['rack.session'].dup Thread.stop - env['rack.session'][(Time.now.usec*rand).to_i] = true + env['rack.session'][(Time.now.usec * rand).to_i] = true incrementor.call(env) end tses = Rack::Utils::Context.new pool, delta_incrementor treq = Rack::MockRequest.new(tses) - tnum = rand(7).to_i+5 + tnum = rand(7).to_i + 5 r = Array.new(tnum) do Thread.new(treq) do |run| run.get('/', "HTTP_COOKIE" => cookie, 'rack.multithread' => true) @@ -180,7 +182,7 @@ describe Rack::Session::Pool do end session = pool.pool[sess_id] - session.size.must_equal tnum+1 # counter + session.size.must_equal tnum + 1 # counter session['counter'].must_equal 2 # meeeh end @@ -197,13 +199,13 @@ describe Rack::Session::Pool do end it "returns even if not read/written if :expire_after is set" do - app = Rack::Session::Pool.new(nothing, :expire_after => 3600) - res = Rack::MockRequest.new(app).get("/", 'rack.session' => {'not' => 'empty'}) + app = Rack::Session::Pool.new(nothing, expire_after: 3600) + res = Rack::MockRequest.new(app).get("/", 'rack.session' => { 'not' => 'empty' }) res["Set-Cookie"].wont_be :nil? end it "returns no cookie if no data was written and no session was created previously, even if :expire_after is set" do - app = Rack::Session::Pool.new(nothing, :expire_after => 3600) + app = Rack::Session::Pool.new(nothing, expire_after: 3600) res = Rack::MockRequest.new(app).get("/") res["Set-Cookie"].must_be_nil end |