Sha256: 06f8538e882e6c612391da32656a4e96c4ad36e5eb78323c88c706aeea27dce3

Contents?: true

Size: 1.36 KB

Versions: 11

Compression:

Stored size: 1.36 KB

Contents

require 'test/spec'
require 'rack/mock'

begin
  require 'rack/contrib/profiler'

  context 'Rack::Profiler' do
    app = lambda { |env| [200, {'Content-Type' => 'text/plain'}, 'Oh hai der'] }
    request = Rack::MockRequest.env_for("/", :input => "profile=process_time")

    specify 'printer defaults to RubyProf::CallTreePrinter' do
      profiler = Rack::Profiler.new(nil)
      profiler.instance_variable_get('@printer').should.equal RubyProf::CallTreePrinter
      profiler.instance_variable_get('@times').should.equal 1
    end

    specify 'CallTreePrinter has correct headers' do
      headers = Rack::Profiler.new(app).call(request)[1]
      headers.should.equal "Content-Disposition"=>"attachment; filename=\"/.process_time.tree\"", "Content-Type"=>"application/octet-stream"
    end

    specify 'FlatPrinter and GraphPrinter has Content-Type text/plain' do
      %w(flat graph).each do |printer|
        headers = Rack::Profiler.new(app, :printer => printer.to_sym).call(request)[1]
        headers.should.equal "Content-Type"=>"text/plain"
      end
    end

    specify 'GraphHtmlPrinter has Content-Type text/html' do
      headers = Rack::Profiler.new(app, :printer => :graph_html).call(request)[1]
      headers.should.equal "Content-Type"=>"text/html"
    end
  end

rescue LoadError => boom
  $stderr.puts "WARN: Skipping Rack::Profiler tests (ruby-prof not installed)"
end

Version data entries

11 entries across 11 versions & 6 rubygems

Version Path
cavalle-rack-contrib-1.0.0 test/spec_rack_profiler.rb
rack-rack-contrib-0.9.1 test/spec_rack_profiler.rb
rack-rack-contrib-0.9.2 test/spec_rack_profiler.rb
tricycle-rack-contrib-0.9.3 test/spec_rack_profiler.rb
rack-contrib_stringbot-0.9.3 test/spec_rack_profiler.rb
tricycle-rack-contrib-0.9.7 test/spec_rack_profiler.rb
tricycle-rack-contrib-0.9.6 test/spec_rack_profiler.rb
tricycle-rack-contrib-0.9.5 test/spec_rack_profiler.rb
tricycle-rack-contrib-0.9.0 test/spec_rack_profiler.rb
rack-contrib-with-working-jsonp-0.9.2.1 test/spec_rack_profiler.rb
rack-contrib-0.9.2 test/spec_rack_profiler.rb