Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added bundler tests for multi-request

  • Loading branch information...
commit a972627520a58ff0fb0584ea5c0740b1344adb74 1 parent a99582f
@bhb bhb authored
View
23 test/multiple_request_profiling_test.rb
@@ -123,6 +123,29 @@ def profile_requests(profiled_app, requests, options = {})
status, headers, body = profiled_app.call(custom_data_env)
assert_no_match(/method1/, RackResponseBody.new(body).to_s)
end
+
+ context "when in bundler mode" do
+
+ should "call pprof.rb using 'bundle' command if bundler is set" do
+ status = stub_everything(:exitstatus => 0)
+ profiled_app = Rack::PerftoolsProfiler.new(@app, :bundler => true)
+ Open4.expects(:popen4).with(regexp_matches(/^bundle exec pprof\.rb/)).returns(status)
+ profile_requests(profiled_app, :default)
+ end
+
+ should "change directory into the current directory if custom Gemfile dir is not provided" do
+ profiled_app = Rack::PerftoolsProfiler.new(@app, :bundler => true, :gemfile_dir => 'bundler')
+ Dir.expects(:chdir).with('bundler').returns(["","",0])
+ profile_requests(profiled_app, :default)
+ end
+
+ should "change directory into custom Gemfile dir if provided" do
+ profiled_app = Rack::PerftoolsProfiler.new(@app, :bundler => true)
+ Dir.expects(:chdir).with('.').returns(["","",0])
+ profile_requests(profiled_app, :default)
+ end
+
+ end
end
View
23 test/rack-perftools-profiler_test.rb
@@ -80,29 +80,6 @@ class RackPerftoolsProfilerTest < Test::Unit::TestCase
end
- context "when in bundler mode" do
-
- should "call pprof.rb using 'bundle' command if bundler is set" do
- status = stub_everything(:exitstatus => 0)
- profiled_app = Rack::PerftoolsProfiler.new(@app, :bundler => true)
- Open4.expects(:popen4).with(regexp_matches(/^bundle exec pprof\.rb/)).returns(status)
- profiled_app.call(@profiled_request_env)
- end
-
- should "change directory into the current directory if custom Gemfile dir is not provided" do
- profiled_app = Rack::PerftoolsProfiler.new(@app, :bundler => true, :gemfile_dir => 'bundler')
- Dir.expects(:chdir).with('bundler').returns(["","",0])
- profiled_app.call(@profiled_request_env)
- end
-
- should "change directory into custom Gemfile dir if provided" do
- profiled_app = Rack::PerftoolsProfiler.new(@app, :bundler => true)
- Dir.expects(:chdir).with('.').returns(["","",0])
- profiled_app.call(@profiled_request_env)
- end
-
- end
-
context "when changing mode for single request" do
should "default to configured mode if mode is empty string" do
View
23 test/single_request_profiling_test.rb
@@ -92,6 +92,29 @@ def setup
assert_no_match(/method1/, RackResponseBody.new(body).to_s)
end
+ context "when in bundler mode" do
+
+ should "call pprof.rb using 'bundle' command if bundler is set" do
+ status = stub_everything(:exitstatus => 0)
+ profiled_app = Rack::PerftoolsProfiler.new(@app, :bundler => true)
+ Open4.expects(:popen4).with(regexp_matches(/^bundle exec pprof\.rb/)).returns(status)
+ profiled_app.call(@profiled_request_env)
+ end
+
+ should "change directory into the current directory if custom Gemfile dir is not provided" do
+ profiled_app = Rack::PerftoolsProfiler.new(@app, :bundler => true, :gemfile_dir => 'bundler')
+ Dir.expects(:chdir).with('bundler').returns(["","",0])
+ profiled_app.call(@profiled_request_env)
+ end
+
+ should "change directory into custom Gemfile dir if provided" do
+ profiled_app = Rack::PerftoolsProfiler.new(@app, :bundler => true)
+ Dir.expects(:chdir).with('.').returns(["","",0])
+ profiled_app.call(@profiled_request_env)
+ end
+
+ end
+
end
context 'when using the text printer' do
Please sign in to comment.
Something went wrong with that request. Please try again.