public
Rubygem
Description: Suppresses the noise in your Test::Unit backtraces
Homepage: http://www.thoughtbot.com/projects/quietbacktrace
Clone URL: git://github.com/thoughtbot/quietbacktrace.git
debugging why Ruby.framework/benchmark.rb cannot be removed from 
backtrace. also, cleaning up lib so lines are viewable in a normal width 
editory (under 80-90 chars wide)
dancroak (author)
Sat Jun 07 13:04:38 -0700 2008
commit  5e9b7ffc91ba7a64dbc248c9f118d53c1ad07ac7
tree    3de213082d9d443a3521e2e9f9b9305c9ab2170b
parent  8ff1df35636d7b318e60b415f1f21b240610ccb4
...
97
98
99
 
100
101
102
...
125
126
127
128
129
130
131
132
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
133
134
135
 
 
 
 
 
 
136
137
138
 
139
140
141
...
97
98
99
100
101
102
103
...
126
127
128
 
 
 
 
 
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
 
 
147
148
149
150
151
152
153
154
 
155
156
157
158
0
@@ -97,6 +97,7 @@ module QuietBacktrace # :nodoc: all
0
     def filter_backtrace_with_quieting(backtrace)
0
       filter_backtrace_without_quieting(backtrace)
0
 
0
+ # Rails view backtraces are flattened into one String. Adjust.
0
       backtrace = backtrace.first.split("\n") if backtrace.size == 1
0
 
0
       if Test::Unit::TestCase.quiet_backtrace
0
@@ -125,17 +126,33 @@ module QuietBacktrace # :nodoc: all
0
         
0
         extend ClassMethods
0
         
0
- new_backtrace_silencer(:test_unit) { |line| (line.include?("ruby") && line.include?("/test/unit")) }
0
- new_backtrace_silencer(:ruby_framework) { |line| line =~ /Ruby.framework/i || line =~ /usr\/lib\/ruby/ }
0
- new_backtrace_silencer(:gem_root) { |line| line =~ /ruby\/gems/i }
0
- new_backtrace_silencer(:e1) { |line| line == "-e:1" }
0
- new_backtrace_silencer(:rails_vendor) { |line| (line.include?("vendor/plugins") || line.include?("vendor/gems") || line.include?("vendor/rails")) }
0
+ new_backtrace_silencer(:test_unit) do |line|
0
+ (line.include?("ruby") && line.include?("/test/unit"))
0
+ end
0
+ new_backtrace_silencer(:os_x_ruby) do |line|
0
+ line.include?(/ruby\/1\.8\/benchmark/)
0
+ end
0
+ new_backtrace_silencer(:gem_root) do |line|
0
+ line =~ /ruby\/gems/i
0
+ end
0
+ new_backtrace_silencer(:e1) do |line|
0
+ line == "-e:1"
0
+ end
0
+ new_backtrace_silencer(:rails_vendor) do |line|
0
+ (line.include?("vendor/plugins") ||
0
+ line.include?("vendor/gems") ||
0
+ line.include?("vendor/rails"))
0
+ end
0
         
0
- new_backtrace_filter(:method_name) { |line| line.slice!((line =~ /:in /)..line.length) if (line =~ /:in /) }
0
- new_backtrace_filter(:rails_root) { |line| line.sub!("#{RAILS_ROOT}/", '') if (defined?(RAILS_ROOT) && line.include?(RAILS_ROOT)) }
0
+ new_backtrace_filter(:method_name) do |line|
0
+ line.slice!((line =~ /:in /)..line.length) if (line =~ /:in /)
0
+ end
0
+ new_backtrace_filter(:rails_root) do |line|
0
+ line.sub!("#{RAILS_ROOT}/", '') if (defined?(RAILS_ROOT) && line.include?(RAILS_ROOT))
0
+ end
0
         
0
         self.quiet_backtrace = true
0
- self.backtrace_silencers = [:test_unit, :gem_root, :e1]
0
+ self.backtrace_silencers = [:test_unit, :os_x_ruby, :gem_root, :e1]
0
         self.backtrace_filters = [:method_name]
0
       end
0
     end
...
37
38
39
40
 
 
41
42
43
...
53
54
55
56
 
57
58
59
...
69
70
71
72
 
73
74
75
...
85
86
87
88
 
89
90
91
...
37
38
39
 
40
41
42
43
44
...
54
55
56
 
57
58
59
60
...
70
71
72
 
73
74
75
76
...
86
87
88
 
89
90
91
92
0
@@ -37,7 +37,8 @@ class QuietBacktraceTest < Test::Unit::TestCase # :nodoc:
0
     @backtrace = [ "/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/test/unit/assertions.rb:48:in `assert_block'",
0
                    "/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/test/unit/assertions.rb:495:in `_wrap_assertion'",
0
                    "/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/test/unit/assertions.rb:46:in `assert_block'",
0
- "/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/test/unit/assertions.rb:313:in `flunk'",
0
+ "/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/test/unit/assertions.rb:313:in `flunk'",
0
+ "/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/benchmark.rb:293",
0
                    "/Users/james/Documents/railsApps/generating_station/app/controllers/photos_controller.rb:315:in `something'",
0
                    "/Users/james/Documents/railsApps/generating_station/vendor/plugins/quiet_stacktraces/test/quiet_stacktraces_test.rb:21:in `test_this_plugin'",
0
                    "/Users/james/Documents/railsApps/generating_station/vendor/plugins/quiet_stacktraces/quiet_stacktraces_test.rb:25:in `test_this_plugin'",
0
@@ -53,7 +54,7 @@ class QuietBacktraceTest < Test::Unit::TestCase # :nodoc:
0
                    "/Users/james/Documents/railsApps/generating_station/vendor/plugins/quiet_stacktraces/test/quiet_stacktraces_test.rb:20"]
0
   end
0
   
0
- context "The default quiet backtrace" do
0
+ context "A default quiet backtrace" do
0
     setup do
0
       reset_filter!
0
       @mock = MockTestUnit.new
0
@@ -69,7 +70,7 @@ class QuietBacktraceTest < Test::Unit::TestCase # :nodoc:
0
     end
0
     
0
     should 'silence any line containing Ruby.framework' do
0
- assert !@default_quiet_backtrace.any? { |line| line =~ /Ruby.framework/i }, "One or more lines from Ruby.framework are not being filtered: #{@default_quiet_backtrace}"
0
+ assert !@default_quiet_backtrace.any? { |line| line.include?("Ruby.framework") }, "One or more lines from Ruby.framework are not being filtered: #{@default_quiet_backtrace}"
0
     end
0
     
0
     should "silence any line that includes the e1 nonsense" do
0
@@ -85,7 +86,7 @@ class QuietBacktraceTest < Test::Unit::TestCase # :nodoc:
0
     end
0
   end
0
   
0
- context "The quiet backtrace with complementary Rails silencers and filters" do
0
+ context "A quiet backtrace with complementary Rails silencers and filters" do
0
     setup do
0
       reset_filter!
0
       ::RAILS_ROOT = '/Users/james/Documents/railsApps/generating_station'

Comments

    No one has commented yet.