class StackProf::MiddlewareTest
Public Instance Methods
test_enabled_should_use_a_proc_if_passed()
click to toggle source
# File test/test_middleware.rb, line 41 def test_enabled_should_use_a_proc_if_passed env = {} StackProf::Middleware.new(Object.new, enabled: Proc.new{ false }) refute StackProf::Middleware.enabled?(env) StackProf::Middleware.new(Object.new, enabled: Proc.new{ true }) assert StackProf::Middleware.enabled?(env) end
test_enabled_should_use_a_proc_if_passed_and_use_the_request_env()
click to toggle source
# File test/test_middleware.rb, line 51 def test_enabled_should_use_a_proc_if_passed_and_use_the_request_env enable_proc = Proc.new {|env| env['PROFILE'] } env = Hash.new { false } StackProf::Middleware.new(Object.new, enabled: enable_proc) refute StackProf::Middleware.enabled?(env) env = Hash.new { true } StackProf::Middleware.new(Object.new, enabled: enable_proc) assert StackProf::Middleware.enabled?(env) end
test_path_custom()
click to toggle source
# File test/test_middleware.rb, line 15 def test_path_custom StackProf::Middleware.new(Object.new, { path: 'foo/' }) assert_equal 'foo/', StackProf::Middleware.path end
test_path_default()
click to toggle source
# File test/test_middleware.rb, line 9 def test_path_default StackProf::Middleware.new(Object.new) assert_equal 'tmp/', StackProf::Middleware.path end
test_raw()
click to toggle source
# File test/test_middleware.rb, line 63 def test_raw StackProf::Middleware.new(Object.new, raw: true) assert StackProf::Middleware.raw end
test_save_custom()
click to toggle source
# File test/test_middleware.rb, line 31 def test_save_custom StackProf::Middleware.new(Object.new, { path: 'foo/' }) StackProf.stubs(:results).returns({ mode: 'foo' }) FileUtils.expects(:mkdir_p).with('foo/') File.expects(:open).with(regexp_matches(/^foo\/stackprof-foo/), 'wb') StackProf::Middleware.save end
test_save_default()
click to toggle source
# File test/test_middleware.rb, line 21 def test_save_default StackProf::Middleware.new(Object.new) StackProf.stubs(:results).returns({ mode: 'foo' }) FileUtils.expects(:mkdir_p).with('tmp/') File.expects(:open).with(regexp_matches(/^tmp\/stackprof-foo/), 'wb') StackProf::Middleware.save end