1 require File.dirname(__FILE__) + '/../../spec_helper.rb'
5 describe "QuietBacktraceTweaker" do
7 @error = RuntimeError.new
8 @tweaker = QuietBacktraceTweaker.new
11 it "should not barf on nil backtrace" do
13 @tweaker.tweak_backtrace(@error)
14 end.should_not raise_error
17 it "should remove anything from textmate ruby bundle" do
18 @error.set_backtrace(["/Applications/TextMate.app/Contents/SharedSupport/Bundles/Ruby.tmbundle/Support/tmruby.rb:147"])
19 @tweaker.tweak_backtrace(@error)
20 @error.backtrace.should be_empty
23 it "should remove anything in lib spec dir" do
24 ["expectations", "mocks", "runner"].each do |child|
25 element="/lib/spec/#{child}/anything.rb"
26 @error.set_backtrace([element])
27 @tweaker.tweak_backtrace(@error)
28 unless (@error.backtrace.empty?)
29 raise("Should have tweaked away '#{element}'")
34 it "should remove mock_frameworks/rspec" do
35 element = "mock_frameworks/rspec"
36 @error.set_backtrace([element])
37 @tweaker.tweak_backtrace(@error)
38 unless (@error.backtrace.empty?)
39 raise("Should have tweaked away '#{element}'")
43 it "should remove bin spec" do
44 @error.set_backtrace(["bin/spec:"])
45 @tweaker.tweak_backtrace(@error)
46 @error.backtrace.should be_empty
49 it "should clean up double slashes" do
50 @error.set_backtrace(["/a//b/c//d.rb"])
51 @tweaker.tweak_backtrace(@error)
52 @error.backtrace.should include("/a/b/c/d.rb")