Skip to content

Commit

Permalink
Add 100 extra wrappers and 0.1s delay to ensure timing test produces …
Browse files Browse the repository at this point in the history
…measurable results.
  • Loading branch information
headius committed Jan 17, 2010
1 parent 7b995a0 commit fb0a737
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions test/spec_rack_runtime.rb
Expand Up @@ -22,10 +22,16 @@
end

specify "should allow multiple timers to be set" do
app = lambda { |env| [200, {'Content-Type' => 'text/plain'}, "Hello, World!"] }
runtime1 = Rack::Runtime.new(app, "App")
runtime2 = Rack::Runtime.new(runtime1, "All")
response = runtime2.call({})
app = lambda { |env| sleep 0.1; [200, {'Content-Type' => 'text/plain'}, "Hello, World!"] }
runtime = Rack::Runtime.new(app, "App")

# wrap many times to guarantee a measurable difference
100.times do |i|
runtime = Rack::Runtime.new(runtime, i.to_s)
end
runtime = Rack::Runtime.new(runtime, "All")

response = runtime.call({})

response[1]['X-Runtime-App'].should =~ /[\d\.]+/
response[1]['X-Runtime-All'].should =~ /[\d\.]+/
Expand Down

0 comments on commit fb0a737

Please sign in to comment.