test/unit/test_tracy.rb in stack_tracy-0.1.3 vs test/unit/test_tracy.rb in stack_tracy-0.1.4
- old
+ new
@@ -23,11 +23,11 @@
end
it "should be configurable" do
StackTracy.config do |c|
assert_equal true, c.is_a?(Struct)
- assert_equal [:dump_dir, :only, :exclude], c.members
+ assert_equal [:dump_dir, :dump_source_location, :limit, :threshold, :only, :exclude], c.members
c.only = "Kernel"
c.exclude = ["IO", "String"]
end
assert_equal({:only => "Kernel", :exclude => ["IO", "String"]}, StackTracy.send(:merge_options))
@@ -75,12 +75,12 @@
assert hash.delete(:nsec)
hash.delete(:time)
end
}
- assert StackTracy.stack_trace.first.call?
- assert !StackTracy.stack_trace.first.return?
+ assert_equal true, StackTracy.stack_trace.first.call?
+ assert_equal false, StackTracy.stack_trace.first.return?
StackTracy.config do |c|
c.exclude = ["IO"]
end
stack_tracy do
@@ -126,9 +126,33 @@
assert hash.delete(:nsec)
assert hash.delete(:duration)
hash.delete(:time)
end
}
+ end
+
+ it "should clear StackTracy.stack_trace after having invoked StackTracy.dump" do
+ stack_tracy do
+ puts "testing"
+ end
+ assert_equal false, StackTracy.stack_trace.empty?
+
+ StackTracy.dump
+ assert_equal true, StackTracy.stack_trace.empty?
+
+ stack_tracy do
+ puts "testing"
+ end
+ assert_equal false, StackTracy.stack_trace.empty?
+
+ StackTracy.expects(:foo)
+ StackTracy.dump do |file|
+ assert file.match(/\/.*\.csv/)
+ assert_equal false, StackTracy.stack_trace.empty?
+ StackTracy.foo
+ end
+
+ assert_equal true, StackTracy.stack_trace.empty?
end
it "should filter methods as expected" do
stack_tracy do
puts "testing"
\ No newline at end of file