rack-insight 0.5.27 → 0.5.28
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +32 -0
- data/README.md +32 -7
- data/lib/rack/insight/app.rb +5 -0
- data/lib/rack/insight/config.rb +6 -2
- data/lib/rack/insight/enable-button.rb +3 -4
- data/lib/rack/insight/panels/request_variables_panel.rb +4 -1
- data/lib/rack/insight/public/__insight__/insight.js +134 -128
- data/lib/rack/insight/toolbar.rb +9 -6
- data/lib/rack/insight/version.rb +1 -1
- data/lib/rack/insight/views/toolbar.html.erb +11 -9
- metadata +69 -105
- checksums.yaml +0 -7
- data/.gitignore +0 -13
- data/.rspec +0 -1
- data/.ruby-gemset +0 -1
- data/.ruby-version +0 -1
- data/.simplecov +0 -4
- data/.travis.yml +0 -10
- data/Gemfile +0 -3
- data/Gemfile.lock +0 -69
- data/TODO +0 -9
- data/rack-insight.gemspec +0 -42
- data/spec/custom_matchers.rb +0 -0
- data/spec/fixtures/config.ru +0 -8
- data/spec/fixtures/dummy_panel.rb +0 -2
- data/spec/fixtures/sample_app.rb +0 -72
- data/spec/fixtures/star_trek_panel.rb +0 -6
- data/spec/fixtures/views/star_trek.html.erb +0 -17
- data/spec/insight_spec.rb +0 -166
- data/spec/instrumentation_spec.rb +0 -231
- data/spec/rack/insight/config_spec.rb +0 -22
- data/spec/rack/insight/panels/active_record_panel_spec.rb +0 -44
- data/spec/rack/insight/panels/active_resource_panel_spec.rb +0 -40
- data/spec/rack/insight/panels/cache_panel_spec.rb +0 -179
- data/spec/rack/insight/panels/log_panel_spec.rb +0 -43
- data/spec/rack/insight/panels/memory_panel_spec.rb +0 -21
- data/spec/rack/insight/panels/mongo_panel_spec_pending.rb +0 -52
- data/spec/rack/insight/panels/rails_info_panel_spec.rb +0 -30
- data/spec/rack/insight/panels/redis_panel_spec.rb +0 -82
- data/spec/rack/insight/panels/speedtracer_panel_spec.rb +0 -87
- data/spec/rack/insight/panels/sql_panel_spec.rb +0 -150
- data/spec/rack/insight/panels/templates_panel_spec.rb +0 -88
- data/spec/rack/insight/panels/timer_panel_spec.rb +0 -39
- data/spec/rcov.opts +0 -1
- data/spec/spec.opts +0 -1
- data/spec/spec_helper.rb +0 -120
@@ -1,88 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'rack/insight/panels/templates_panel'
|
3
|
-
|
4
|
-
module Rack::Insight
|
5
|
-
describe "TemplatesPanel" do
|
6
|
-
before do
|
7
|
-
mock_constant("ActionView::Template")
|
8
|
-
reset_insight :panel_classes => [Rack::Insight::TemplatesPanel]
|
9
|
-
end
|
10
|
-
|
11
|
-
describe "heading" do
|
12
|
-
it "displays the total rendering time" do
|
13
|
-
response = get_via_rack "/"
|
14
|
-
response.should have_heading("Templates: 0.00ms")
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
def mock_template(path)
|
19
|
-
template = double("ActionView::Template")
|
20
|
-
template.stub(:virtual_path => path)
|
21
|
-
template
|
22
|
-
end
|
23
|
-
|
24
|
-
describe "content" do
|
25
|
-
it "displays the template paths" do
|
26
|
-
app.before_return do
|
27
|
-
mock_method_call("ActionView::Template", :render, [], :instance, mock_template("users/show"))
|
28
|
-
end
|
29
|
-
response = get_via_rack "/"
|
30
|
-
response.should contain("users/show")
|
31
|
-
end
|
32
|
-
|
33
|
-
it "displays the template children" do
|
34
|
-
app.before_return do
|
35
|
-
mock_method_call("ActionView::Template", :render, [], :instance, mock_template("users/show")) do
|
36
|
-
mock_method_call("ActionView::Template", :render, [], :instance, mock_template("users/toolbar"))
|
37
|
-
end
|
38
|
-
end
|
39
|
-
response = get_via_rack "/"
|
40
|
-
response.should have_selector("div.panel_content#TemplatesPanel", :content => "users/show") do |li|
|
41
|
-
li.should contain("users/toolbar")
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
context "for templates that rendered templates" do
|
46
|
-
it "displays the total time" do
|
47
|
-
app.before_return do
|
48
|
-
mock_method_call("ActionView::Template", :render, [], :instance, mock_template("users/show")) do
|
49
|
-
mock_method_call("ActionView::Template", :render, [], :instance, mock_template("users/toolbar"))
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
response = get_via_rack "/"
|
54
|
-
response.should have_selector("div.panel_content#TemplatesPanel", :content => "users/show") do |li|
|
55
|
-
li.should contain(TIME_MS_REGEXP)
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
it "displays the exclusive and child times" do
|
60
|
-
app.before_return do
|
61
|
-
mock_method_call("ActionView::Template", :render, [], :instance, mock_template("users/show")) do
|
62
|
-
mock_method_call("ActionView::Template", :render, [], :instance, mock_template("users/toolbar"))
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
response = get_via_rack "/"
|
67
|
-
response.should have_selector("div.panel_content#TemplatesPanel", :content => "users/show") do |li|
|
68
|
-
li.should contain(/exclusive: \d\.\d{2}ms/)
|
69
|
-
li.should contain(/child: \d\.\d{2}ms/)
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
context "for leaf templates" do
|
75
|
-
it "does not display the exclusive time" do
|
76
|
-
app.before_return do
|
77
|
-
mock_method_call("ActionView::Template", :render, [], :instance, mock_template("users/show"))
|
78
|
-
end
|
79
|
-
|
80
|
-
response = get_via_rack "/"
|
81
|
-
response.should contain("users/show") do |li|
|
82
|
-
li.should_not contain("exclusive")
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|
88
|
-
end
|
@@ -1,39 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'rack/insight/panels/timer_panel'
|
3
|
-
|
4
|
-
module Rack::Insight
|
5
|
-
describe "TimerPanel" do
|
6
|
-
before do
|
7
|
-
reset_insight :panel_classes => [Rack::Insight::TimerPanel]
|
8
|
-
end
|
9
|
-
|
10
|
-
describe "heading" do
|
11
|
-
it "displays the elapsed time" do
|
12
|
-
response = get_via_rack "/"
|
13
|
-
response.should have_heading(TIME_MS_REGEXP)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
describe "content" do
|
18
|
-
it "displays the user CPU time" do
|
19
|
-
response = get_via_rack "/"
|
20
|
-
response.should have_row("table.sortable", "User CPU time", TIME_MS_REGEXP)
|
21
|
-
end
|
22
|
-
|
23
|
-
it "displays the system CPU time" do
|
24
|
-
response = get_via_rack "/"
|
25
|
-
response.should have_row("table.sortable", "System CPU time", TIME_MS_REGEXP)
|
26
|
-
end
|
27
|
-
|
28
|
-
it "displays the total CPU time" do
|
29
|
-
response = get_via_rack "/"
|
30
|
-
response.should have_row("table.sortable", "Total CPU time", TIME_MS_REGEXP)
|
31
|
-
end
|
32
|
-
|
33
|
-
it "displays the elapsed time" do
|
34
|
-
response = get_via_rack "/"
|
35
|
-
response.should have_row("table.sortable", "Elapsed time", TIME_MS_REGEXP)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
data/spec/rcov.opts
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
-x gems,spec\/
|
data/spec/spec.opts
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
--color
|
data/spec/spec_helper.rb
DELETED
@@ -1,120 +0,0 @@
|
|
1
|
-
require "rubygems"
|
2
|
-
require "webrat"
|
3
|
-
require "rack/test"
|
4
|
-
|
5
|
-
RAILS_ENV = "test"
|
6
|
-
|
7
|
-
#$LOAD_PATH.unshift File.dirname(File.dirname(__FILE__)) + '/lib'
|
8
|
-
#$LOAD_PATH.unshift File.dirname(File.dirname(__FILE__))
|
9
|
-
|
10
|
-
require "rack-insight"
|
11
|
-
require "fixtures/sample_app"
|
12
|
-
require "fixtures/dummy_panel"
|
13
|
-
require "rack/insight/rspec_matchers"
|
14
|
-
|
15
|
-
# Will use the default Ruby Logger.
|
16
|
-
Rack::Insight::Config.configure do |config|
|
17
|
-
config[:verbosity] = Rack::Insight::Config::VERBOSITY[:silent]
|
18
|
-
config[:log_level] = ::Logger::INFO
|
19
|
-
end
|
20
|
-
puts "Log Level for specs is #{::Logger::ERROR}"
|
21
|
-
puts "Verbosity level for specs is #{Rack::Insight::Config::VERBOSITY.select {|k,v| v == Rack::Insight::Config.verbosity }.keys.first.inspect} or #{Rack::Insight::Config.verbosity}"
|
22
|
-
|
23
|
-
RSpec.configure do |config|
|
24
|
-
config.treat_symbols_as_metadata_keys_with_true_values = true
|
25
|
-
config.run_all_when_everything_filtered = true
|
26
|
-
config.filter_run :focus
|
27
|
-
|
28
|
-
# Run specs in random order to surface order dependencies. If you find an
|
29
|
-
# order dependency and want to debug it, you can fix the order by providing
|
30
|
-
# the seed, which is printed after each run.
|
31
|
-
# --seed 1234
|
32
|
-
# TODO: Turn this on. Currently off because the specs bleed, and will randomly fail when run randomly.
|
33
|
-
#config.order = 'random'
|
34
|
-
|
35
|
-
TIME_MS_REGEXP = /\d+\.\d{2}ms/
|
36
|
-
|
37
|
-
config.include Rack::Test::Methods
|
38
|
-
config.include Webrat::Matchers
|
39
|
-
config.include Rack::Insight::RspecMatchers
|
40
|
-
|
41
|
-
config.before do
|
42
|
-
@added_constants = []
|
43
|
-
end
|
44
|
-
|
45
|
-
config.after do
|
46
|
-
@added_constants.each do |parent, added|
|
47
|
-
parent.send :remove_const, added
|
48
|
-
end
|
49
|
-
@added_constants.clear
|
50
|
-
end
|
51
|
-
|
52
|
-
config.after :suite do
|
53
|
-
# Clear the database between runs
|
54
|
-
system(*%w{rm -f rack-insight.sqlite})
|
55
|
-
Rack::Insight::Database.reset
|
56
|
-
end
|
57
|
-
|
58
|
-
def reset_insight(options=nil)
|
59
|
-
app.prototype
|
60
|
-
app.insight_app.reset(options)
|
61
|
-
|
62
|
-
Rack::Insight.enable
|
63
|
-
|
64
|
-
set_cookie "rack-insight_enabled=1"
|
65
|
-
end
|
66
|
-
|
67
|
-
def reset_config(config_options = {:panel_load_paths => [File::join('rack', 'insight', 'panels')]})
|
68
|
-
Rack::Insight::Config.configure do |config|
|
69
|
-
# spec folder is in the load path during specs!
|
70
|
-
config[:panel_load_paths] = config_options[:panel_load_paths]
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
def app
|
75
|
-
SampleApp
|
76
|
-
end
|
77
|
-
|
78
|
-
def mock_constant(name)
|
79
|
-
parts = name.split("::")
|
80
|
-
klass = parts.pop
|
81
|
-
mod = parts.inject(Object) do |const, part|
|
82
|
-
begin
|
83
|
-
const.const_get(part)
|
84
|
-
rescue NameError
|
85
|
-
@added_constants << [const, part]
|
86
|
-
mod = Module.new
|
87
|
-
const.const_set(part.to_sym, mod)
|
88
|
-
mod
|
89
|
-
end
|
90
|
-
end
|
91
|
-
begin
|
92
|
-
mod.const_get(klass)
|
93
|
-
rescue NameError
|
94
|
-
mod.const_set(klass, Class.new)
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
def mock_method_call(context, method, args=[], kind=:instance, object=Object.new, &block)
|
99
|
-
mock_constant(context)
|
100
|
-
|
101
|
-
called_at = caller[0]
|
102
|
-
file, line, real_method = called_at.split(":")
|
103
|
-
called_at = [file,line,method].join(":")
|
104
|
-
|
105
|
-
block ||= proc {}
|
106
|
-
|
107
|
-
Rack::Insight::Instrumentation::Probe::ProbeRunner.probe_run(
|
108
|
-
object, context, kind, args, called_at, method, &block)
|
109
|
-
end
|
110
|
-
|
111
|
-
def rack_env(key, value)
|
112
|
-
@rack_env ||= {}
|
113
|
-
@rack_env[key] = value
|
114
|
-
end
|
115
|
-
|
116
|
-
def get_via_rack(uri, params = {}, env = {}, &block)
|
117
|
-
env = env.merge(@rack_env) if @rack_env
|
118
|
-
get(uri, params, env, &block)
|
119
|
-
end
|
120
|
-
end
|