added 'times' to be called in the query string #52

Closed
wants to merge 1 commit into
from
@@ -27,6 +27,7 @@ def initialize(app, options = {})
def call(env)
if mode = profiling?(env)
+ @times = @request.params['times'].to_i if @request.params['times']
profile(env, mode)
else
@app.call(env)
@@ -36,8 +37,8 @@ def call(env)
private
def profiling?(env)
unless ::RubyProf.running?
- request = Rack::Request.new(env.clone)
- if mode = request.params.delete('profile')
+ @request = Rack::Request.new(env.clone)
+ if mode = @request.params.delete('profile')
if ::RubyProf.const_defined?(mode.upcase)
mode
else
View
@@ -4,7 +4,7 @@ Gem::Specification.new do |s|
s.name = 'rack-contrib'
s.version = '1.1.0'
- s.date = '2010-10-19'
+ s.date = '2012-03-08'
s.description = "Contributed Rack Middleware and Utilities"
s.summary = "Contributed Rack Middleware and Utilities"
@@ -14,6 +14,11 @@
profiler.instance_variable_get('@times').should.equal 1
end
+ specify 'call @times globally and times is set' do
+ profiler = Rack::Profiler.new(app, :times => 4)
+ profiler.instance_variable_get('@times').should.equal 4
+ end
+
specify 'CallStackPrinter has Content-Type test/html' do
headers = Rack::Profiler.new(app, :printer => :call_stack).call(request)[1]
headers.should.equal "Content-Type"=>"text/html"