test/rack/session/redis_test.rb in redis-rack-1.3.6 vs test/rack/session/redis_test.rb in redis-rack-1.4.0.rc

- old
+ new

@@ -30,25 +30,15 @@ # lambda{ # Rack::Session::Redis.new(incrementor, :redis_server => 'nosuchserver') # }.must_raise(Exception) # end - it "uses the default Redis server and namespace when not provided" do - pool = Rack::Session::Redis.new(incrementor) - pool.pool.to_s.must_match(/127\.0\.0\.1:6379 against DB 0 with namespace rack:session$/) - end - - it "uses the specified namespace when provided" do + it "passes options to Redis" do pool = Rack::Session::Redis.new(incrementor, :redis_server => {:namespace => 'test:rack:session'}) - pool.pool.to_s.must_match(/namespace test:rack:session$/) + pool.pool.to_s.must_match('namespace test:rack:session') end - it "uses the specified Redis server when provided" do - pool = Rack::Session::Redis.new(incrementor, :redis_server => 'redis://127.0.0.1:6380/1') - pool.pool.to_s.must_match(/127\.0\.0\.1:6380 against DB 1$/) - end - it "creates a new cookie" do pool = Rack::Session::Redis.new(incrementor) res = Rack::MockRequest.new(pool).get("/") res["Set-Cookie"].must_include("#{session_key}=") res.body.must_equal('{"counter"=>1}') @@ -100,27 +90,26 @@ it "maintains freshness" do pool = Rack::Session::Redis.new(incrementor, :expire_after => 3) res = Rack::MockRequest.new(pool).get('/') res.body.must_include('"counter"=>1') cookie = res["Set-Cookie"] - sid = cookie[session_match, 1] res = Rack::MockRequest.new(pool).get('/', "HTTP_COOKIE" => cookie) - res["Set-Cookie"][session_match, 1].must_equal(sid) + res["Set-Cookie"].must_equal(cookie) res.body.must_include('"counter"=>2') puts 'Sleeping to expire session' if $DEBUG sleep 4 res = Rack::MockRequest.new(pool).get('/', "HTTP_COOKIE" => cookie) - res["Set-Cookie"][session_match, 1].wont_equal(sid) - res.body.must_include('"counter"=>1') + res["Set-Cookie"].wont_equal(cookie) + res.body.must_include('"counter"=>3') end it "does not send the same session id if it did not change" do pool = Rack::Session::Redis.new(incrementor) req = Rack::MockRequest.new(pool) res0 = req.get("/") - cookie = res0["Set-Cookie"] + cookie = res0["Set-Cookie"][session_match] res0.body.must_equal('{"counter"=>1}') res1 = req.get("/", "HTTP_COOKIE" => cookie) res1["Set-Cookie"].must_be_nil res1.body.must_equal('{"counter"=>2}') @@ -284,6 +273,6 @@ session = pool.pool.get(session_id) session.size.must_equal(r.size+1) session['counter'].must_be_nil session['foo'].must_equal('bar') end -end +end \ No newline at end of file