test/test_stackprof.rb in stackprof-0.2.12 vs test/test_stackprof.rb in stackprof-0.2.13

- old
+ new

@@ -1,9 +1,10 @@ $:.unshift File.expand_path('../../lib', __FILE__) require 'stackprof' require 'minitest/autorun' require 'tempfile' +require 'pathname' class StackProfTest < MiniTest::Test def test_info profile = StackProf.run{} assert_equal 1.2, profile[:version] @@ -160,9 +161,35 @@ ret = StackProf.run(mode: :custom, out: tmpfile) do StackProf.sample end assert_equal tmpfile, ret + tmpfile.rewind + profile = Marshal.load(tmpfile.read) + refute_empty profile[:frames] + end + + def test_out_to_path_string + tmpfile = Tempfile.new('stackprof-out') + ret = StackProf.run(mode: :custom, out: tmpfile.path) do + StackProf.sample + end + + refute_equal tmpfile, ret + assert_equal tmpfile.path, ret.path + tmpfile.rewind + profile = Marshal.load(tmpfile.read) + refute_empty profile[:frames] + end + + def test_pathname_out + tmpfile = Tempfile.new('stackprof-out') + pathname = Pathname.new(tmpfile.path) + ret = StackProf.run(mode: :custom, out: pathname) do + StackProf.sample + end + + assert_equal tmpfile.path, ret.path tmpfile.rewind profile = Marshal.load(tmpfile.read) refute_empty profile[:frames] end