Sha256: 8683bac0f6f060dd220f1b82156e6a4372fa042f8243d371ce0862112bfe79f1
Contents?: true
Size: 1.83 KB
Versions: 4
Compression:
Stored size: 1.83 KB
Contents
$:.unshift File.expand_path('../../lib', __FILE__) require 'stackprof' require 'stackprof/middleware' require 'minitest/autorun' require 'mocha/setup' class StackProf::MiddlewareTest < MiniTest::Test def test_path_default StackProf::Middleware.new(Object.new) assert_equal 'tmp', StackProf::Middleware.path end def test_path_custom StackProf::Middleware.new(Object.new, { path: '/foo' }) assert_equal '/foo', StackProf::Middleware.path end 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 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 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 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 def test_raw StackProf::Middleware.new(Object.new, raw: true) assert StackProf::Middleware.raw end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
stackprof-0.2.11 | test/test_middleware.rb |
stackprof-0.2.10 | test/test_middleware.rb |
stackprof-0.2.9 | test/test_middleware.rb |
stackprof-0.2.8 | test/test_middleware.rb |