Permalink
Browse files

Fix local vars on rack session test

  • Loading branch information...
1 parent f5d9963 commit 99c62c4fcb954e4b132a85fb8caa1b0845d87f7d @arthurnn arthurnn committed Jan 9, 2014
Showing with 38 additions and 26 deletions.
  1. +38 −26 test/test_rack_session.rb
View
64 test/test_rack_session.rb
@@ -11,35 +11,47 @@
before do
memcached(19129) do
end
+
+ # test memcache connection
+ Rack::Session::Dalli.new(incrementor)
end
- session_key = Rack::Session::Dalli::DEFAULT_OPTIONS[:key]
- session_match = /#{session_key}=([0-9a-fA-F]+);/
- incrementor = lambda do |env|
- env["rack.session"]["counter"] ||= 0
- env["rack.session"]["counter"] += 1
- Rack::Response.new(env["rack.session"].inspect).to_a
+ let(:session_key) { Rack::Session::Dalli::DEFAULT_OPTIONS[:key] }
+ let(:session_match) do
+ /#{session_key}=([0-9a-fA-F]+);/
+ end
+ let(:incrementor_proc) do
+ lambda do |env|
+ env["rack.session"]["counter"] ||= 0
+ env["rack.session"]["counter"] += 1
+ Rack::Response.new(env["rack.session"].inspect).to_a
+ end
+ end
+ let(:drop_session) do
+ Rack::Lint.new(proc do |env|
+ env['rack.session.options'][:drop] = true
+ incrementor_proc.call(env)
+ end)
+ end
+ let(:renew_session) do
+ Rack::Lint.new(proc do |env|
+ env['rack.session.options'][:renew] = true
+ incrementor_proc.call(env)
+ end)
+ end
+ let(:defer_session) do
+ Rack::Lint.new(proc do |env|
+ env['rack.session.options'][:defer] = true
+ incrementor_proc.call(env)
+ end)
+ end
+ let(:skip_session) do
+ Rack::Lint.new(proc do |env|
+ env['rack.session.options'][:skip] = true
+ incrementor_proc.call(env)
+ end)
end
- drop_session = Rack::Lint.new(proc do |env|
- env['rack.session.options'][:drop] = true
- incrementor.call(env)
- end)
- renew_session = Rack::Lint.new(proc do |env|
- env['rack.session.options'][:renew] = true
- incrementor.call(env)
- end)
- defer_session = Rack::Lint.new(proc do |env|
- env['rack.session.options'][:defer] = true
- incrementor.call(env)
- end)
- skip_session = Rack::Lint.new(proc do |env|
- env['rack.session.options'][:skip] = true
- incrementor.call(env)
- end)
- incrementor = Rack::Lint.new(incrementor)
-
- # test memcache connection
- Rack::Session::Dalli.new(incrementor)
+ let(:incrementor) { Rack::Lint.new(incrementor_proc) }
it "faults on no connection" do
assert_raises Dalli::RingError do

0 comments on commit 99c62c4

Please sign in to comment.