thoughtbot-quietbacktrace 1.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +20 -0
- data/README.markdown +94 -0
- data/lib/aliasing.rb +89 -0
- data/lib/attribute_accessors.rb +131 -0
- data/lib/quietbacktrace.rb +173 -0
- data/quietbacktrace.gemspec +11 -0
- metadata +60 -0
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2007 Dan Croak, thoughtbot, inc.
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.markdown
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
Quiet Backtrace
|
2
|
+
===============
|
3
|
+
|
4
|
+
Quiet Backtrace suppresses the noise in your Test::Unit backtrace.
|
5
|
+
It also provides hooks for you to add additional silencers and filters.
|
6
|
+
|
7
|
+
Install
|
8
|
+
-------
|
9
|
+
|
10
|
+
sudo gem install quietbacktrace
|
11
|
+
|
12
|
+
Usage
|
13
|
+
-----
|
14
|
+
|
15
|
+
Quiet Backtrace works by adding new attributes to Test::Unit::TestCase.
|
16
|
+
By default, their values are:
|
17
|
+
|
18
|
+
self.quiet_backtrace = true
|
19
|
+
self.backtrace_silencers = [:test_unit, :gem_root, :e1]
|
20
|
+
self.backtrace_filters = [:method_name]
|
21
|
+
|
22
|
+
Silencers remove lines from the backtrace that return true for given conditions.
|
23
|
+
Filters modify the output of backtrace lines.
|
24
|
+
|
25
|
+
Override the defaults by adding your own backtrace_silencers:
|
26
|
+
|
27
|
+
class Test::Unit::TestCase
|
28
|
+
self.new_backtrace_silencer :shoulda do |line|
|
29
|
+
line.include? 'vendor/plugins/shoulda'
|
30
|
+
end
|
31
|
+
self.backtrace_silencers << :shoulda
|
32
|
+
end
|
33
|
+
|
34
|
+
Or your own backtrace_filters:
|
35
|
+
|
36
|
+
class Test::Unit::TestCase
|
37
|
+
self.new_backtrace_filter :ruby_path do |line|
|
38
|
+
ruby_file_path = '/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8'
|
39
|
+
line.slice!(0..(line =~ ruby_file_path)) if (line =~ ruby_file_path)
|
40
|
+
end
|
41
|
+
self.backtrace_filters << :ruby_path
|
42
|
+
end
|
43
|
+
|
44
|
+
Turn Quiet Backtrace off anywhere in your test suite by setting the flag to false:
|
45
|
+
|
46
|
+
Test::Unit::TestCase.quiet_backtrace = false
|
47
|
+
|
48
|
+
Rails-specific usage
|
49
|
+
--------------------
|
50
|
+
|
51
|
+
Install the gem and add it your Rails app:
|
52
|
+
|
53
|
+
* gem install thoughtbot-quietbacktrace --source http://gems.github.com
|
54
|
+
* cd vendor/gems
|
55
|
+
* gem unpack quietbacktrace
|
56
|
+
|
57
|
+
Quiet Backtrace comes with an excellent Rails-specific silencer and filter.
|
58
|
+
They must be added (usually in test_helper.rb) because they are not turned on by default:
|
59
|
+
|
60
|
+
class Test::Unit::TestCase
|
61
|
+
self.backtrace_silencers << :rails_vendor
|
62
|
+
self.backtrace_filters << :rails_root
|
63
|
+
end
|
64
|
+
|
65
|
+
Because Quiet Backtrace works by adding attributes onto Test::Unit::TestCase,
|
66
|
+
you can add and remove silencers and filters at any level in your test suite,
|
67
|
+
down to the individual test.
|
68
|
+
|
69
|
+
Requirements
|
70
|
+
------------
|
71
|
+
|
72
|
+
* Test::Unit
|
73
|
+
* aliasing.rb and attribute_accessors.rb, which are sniped from ActiveSupport and
|
74
|
+
are included in the gem. They allow quietbacktrace.rb to use alias method chain,
|
75
|
+
cattr accessor, and mattr accessor.
|
76
|
+
|
77
|
+
Resources
|
78
|
+
---------
|
79
|
+
|
80
|
+
* [mailing list](http://groups.google.com/group/quiet_backtrace)
|
81
|
+
* [project site](http://rubyforge.org/projects/quietbacktrace)
|
82
|
+
|
83
|
+
Authors
|
84
|
+
-------
|
85
|
+
|
86
|
+
* [Dan Croak](http://dancroak.com)
|
87
|
+
* [James Golick](http://jamesgolick.com/)
|
88
|
+
* [Joe Ferris](jferris@thoughtbot.com)
|
89
|
+
|
90
|
+
Special thanks to the [Boston.rb group](http://bostonrb.org)
|
91
|
+
for cultivating this idea at our inaugural hackfest.
|
92
|
+
|
93
|
+
Copyright (c) Dan Croak, James Golick, Joe Ferris, thoughtbot, inc.
|
94
|
+
(the MIT license)
|
data/lib/aliasing.rb
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
# :stopdoc:
|
2
|
+
#
|
3
|
+
# Snipped directly from ActiveSupport from Rails 1.2.3
|
4
|
+
# If Quiet Backtrace is run from a Rails app, the actual ActiveSupport
|
5
|
+
# methods will be used. That way, alias_method_chain will not be
|
6
|
+
# overridden in your Rails app if Quiet Backtrace is installed.
|
7
|
+
#
|
8
|
+
# Copyright (c) 2005-2006 David Heinemeier Hansson
|
9
|
+
#
|
10
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
11
|
+
# a copy of this software and associated documentation files (the
|
12
|
+
# "Software"), to deal in the Software without restriction, including
|
13
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
14
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
15
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
16
|
+
# the following conditions:
|
17
|
+
#
|
18
|
+
# The above copyright notice and this permission notice shall be
|
19
|
+
# included in all copies or substantial portions of the Software.
|
20
|
+
#
|
21
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
22
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
23
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
24
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
25
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
26
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
27
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
28
|
+
|
29
|
+
# activesupport/lib/activesupport/core_ext/module/aliasing.rb
|
30
|
+
unless defined?(ActiveSupport)
|
31
|
+
class Module # :nodoc:
|
32
|
+
# Encapsulates the common pattern of:
|
33
|
+
#
|
34
|
+
# alias_method :foo_without_feature, :foo
|
35
|
+
# alias_method :foo, :foo_with_feature
|
36
|
+
#
|
37
|
+
# With this, you simply do:
|
38
|
+
#
|
39
|
+
# alias_method_chain :foo, :feature
|
40
|
+
#
|
41
|
+
# And both aliases are set up for you.
|
42
|
+
#
|
43
|
+
# Query and bang methods (foo?, foo!) keep the same punctuation:
|
44
|
+
#
|
45
|
+
# alias_method_chain :foo?, :feature
|
46
|
+
#
|
47
|
+
# is equivalent to
|
48
|
+
#
|
49
|
+
# alias_method :foo_without_feature?, :foo?
|
50
|
+
# alias_method :foo?, :foo_with_feature?
|
51
|
+
#
|
52
|
+
# so you can safely chain foo, foo?, and foo! with the same feature.
|
53
|
+
def alias_method_chain(target, feature)
|
54
|
+
# Strip out punctuation on predicates or bang methods since
|
55
|
+
# e.g. target?_without_feature is not a valid method name.
|
56
|
+
aliased_target, punctuation = target.to_s.sub(/([?!=])$/, ''), $1
|
57
|
+
yield(aliased_target, punctuation) if block_given?
|
58
|
+
alias_method "#{aliased_target}_without_#{feature}#{punctuation}", target
|
59
|
+
alias_method target, "#{aliased_target}_with_#{feature}#{punctuation}"
|
60
|
+
end
|
61
|
+
|
62
|
+
# Allows you to make aliases for attributes, which includes
|
63
|
+
# getter, setter, and query methods.
|
64
|
+
#
|
65
|
+
# Example:
|
66
|
+
#
|
67
|
+
# class Content < ActiveRecord::Base
|
68
|
+
# # has a title attribute
|
69
|
+
# end
|
70
|
+
#
|
71
|
+
# class Email < ActiveRecord::Base
|
72
|
+
# alias_attribute :subject, :title
|
73
|
+
# end
|
74
|
+
#
|
75
|
+
# e = Email.find(1)
|
76
|
+
# e.title # => "Superstars"
|
77
|
+
# e.subject # => "Superstars"
|
78
|
+
# e.subject? # => true
|
79
|
+
# e.subject = "Megastars"
|
80
|
+
# e.title # => "Megastars"
|
81
|
+
def alias_attribute(new_name, old_name)
|
82
|
+
module_eval <<-STR, __FILE__, __LINE__+1
|
83
|
+
def #{new_name}; #{old_name}; end
|
84
|
+
def #{new_name}?; #{old_name}?; end
|
85
|
+
def #{new_name}=(v); self.#{old_name} = v; end
|
86
|
+
STR
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
@@ -0,0 +1,131 @@
|
|
1
|
+
# :stopdoc:
|
2
|
+
#
|
3
|
+
# Snipped directly from ActiveSupport from Rails 1.2.3
|
4
|
+
# If Quiet Backtrace is run from a Rails app, the actual ActiveSupport
|
5
|
+
# methods will be used. That way, mattr_accessor and cattr_accessor will
|
6
|
+
# not be overridden in your Rails app if Quiet Backtrace is installed.
|
7
|
+
#
|
8
|
+
# Copyright (c) 2005-2006 David Heinemeier Hansson
|
9
|
+
#
|
10
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
11
|
+
# a copy of this software and associated documentation files (the
|
12
|
+
# "Software"), to deal in the Software without restriction, including
|
13
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
14
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
15
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
16
|
+
# the following conditions:
|
17
|
+
#
|
18
|
+
# The above copyright notice and this permission notice shall be
|
19
|
+
# included in all copies or substantial portions of the Software.
|
20
|
+
#
|
21
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
22
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
23
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
24
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
25
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
26
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
27
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
28
|
+
|
29
|
+
# activesupport/lib/activesupport/core_ext/module/attribute_accessors.rb
|
30
|
+
#
|
31
|
+
# Extends the module object with module and instance accessors for class attributes,
|
32
|
+
# just like the native attr* accessors for instance attributes.
|
33
|
+
unless defined?(ActiveSupport)
|
34
|
+
class Module # :nodoc:
|
35
|
+
def mattr_reader(*syms)
|
36
|
+
syms.each do |sym|
|
37
|
+
next if sym.is_a?(Hash)
|
38
|
+
class_eval(<<-EOS, __FILE__, __LINE__)
|
39
|
+
unless defined? @@#{sym}
|
40
|
+
@@#{sym} = nil
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.#{sym}
|
44
|
+
@@#{sym}
|
45
|
+
end
|
46
|
+
|
47
|
+
def #{sym}
|
48
|
+
@@#{sym}
|
49
|
+
end
|
50
|
+
EOS
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def mattr_writer(*syms)
|
55
|
+
options = syms.last.is_a?(Hash) ? syms.pop : {}
|
56
|
+
syms.each do |sym|
|
57
|
+
class_eval(<<-EOS, __FILE__, __LINE__)
|
58
|
+
unless defined? @@#{sym}
|
59
|
+
@@#{sym} = nil
|
60
|
+
end
|
61
|
+
|
62
|
+
def self.#{sym}=(obj)
|
63
|
+
@@#{sym} = obj
|
64
|
+
end
|
65
|
+
|
66
|
+
#{"
|
67
|
+
def #{sym}=(obj)
|
68
|
+
@@#{sym} = obj
|
69
|
+
end
|
70
|
+
" unless options[:instance_writer] == false }
|
71
|
+
EOS
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def mattr_accessor(*syms)
|
76
|
+
mattr_reader(*syms)
|
77
|
+
mattr_writer(*syms)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
# activesupport/lib/activesupport/core_ext/class/attribute_accessors.rb
|
82
|
+
|
83
|
+
# Extends the class object with class and instance accessors for class attributes,
|
84
|
+
# just like the native attr* accessors for instance attributes.
|
85
|
+
class Class # :nodoc:
|
86
|
+
def cattr_reader(*syms)
|
87
|
+
syms.flatten.each do |sym|
|
88
|
+
next if sym.is_a?(Hash)
|
89
|
+
class_eval(<<-EOS, __FILE__, __LINE__)
|
90
|
+
unless defined? @@#{sym}
|
91
|
+
@@#{sym} = nil
|
92
|
+
end
|
93
|
+
|
94
|
+
def self.#{sym}
|
95
|
+
@@#{sym}
|
96
|
+
end
|
97
|
+
|
98
|
+
def #{sym}
|
99
|
+
@@#{sym}
|
100
|
+
end
|
101
|
+
EOS
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
def cattr_writer(*syms)
|
106
|
+
options = syms.last.is_a?(Hash) ? syms.pop : {}
|
107
|
+
syms.flatten.each do |sym|
|
108
|
+
class_eval(<<-EOS, __FILE__, __LINE__)
|
109
|
+
unless defined? @@#{sym}
|
110
|
+
@@#{sym} = nil
|
111
|
+
end
|
112
|
+
|
113
|
+
def self.#{sym}=(obj)
|
114
|
+
@@#{sym} = obj
|
115
|
+
end
|
116
|
+
|
117
|
+
#{"
|
118
|
+
def #{sym}=(obj)
|
119
|
+
@@#{sym} = obj
|
120
|
+
end
|
121
|
+
" unless options[:instance_writer] == false }
|
122
|
+
EOS
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
def cattr_accessor(*syms)
|
127
|
+
cattr_reader(*syms)
|
128
|
+
cattr_writer(*syms)
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
@@ -0,0 +1,173 @@
|
|
1
|
+
# = Quiet Backtrace
|
2
|
+
#
|
3
|
+
# Quiet Backtrace suppresses the noise in your Test::Unit backtrace.
|
4
|
+
# It also provides hooks for you to add additional silencers and filters.
|
5
|
+
#
|
6
|
+
# == Install
|
7
|
+
#
|
8
|
+
# sudo gem install quietbacktrace
|
9
|
+
#
|
10
|
+
# == Usage
|
11
|
+
#
|
12
|
+
# Quiet Backtrace works by adding new attributes to Test::Unit::TestCase.
|
13
|
+
# By default, their values are:
|
14
|
+
# self.quiet_backtrace = true
|
15
|
+
# self.backtrace_silencers = [:test_unit, :gem_root, :e1]
|
16
|
+
# self.backtrace_filters = [:method_name]
|
17
|
+
#
|
18
|
+
# Silencers remove lines from the backtrace that return true for given conditions.
|
19
|
+
# Filters modify the output of backtrace lines.
|
20
|
+
#
|
21
|
+
# Override the defaults by adding your own backtrace_silencers:
|
22
|
+
# class Test::Unit::TestCase
|
23
|
+
# self.backtrace_silencers :shoulda do |line|
|
24
|
+
# line.include? 'vendor/plugins/shoulda'
|
25
|
+
# end
|
26
|
+
# end
|
27
|
+
#
|
28
|
+
# Or your own backtrace_filters:
|
29
|
+
# class Test::Unit::TestCase
|
30
|
+
# self.backtrace_filters :ruby_path do |line|
|
31
|
+
# ruby_file_path = '/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8'
|
32
|
+
# line.slice!(0..(line =~ ruby_file_path)) if (line =~ ruby_file_path)
|
33
|
+
# end
|
34
|
+
# end
|
35
|
+
#
|
36
|
+
# Turn Quiet Backtrace off anywhere in your test suite by setting the flag to false:
|
37
|
+
# Test::Unit::TestCase.quiet_backtrace = false
|
38
|
+
#
|
39
|
+
# == Rails-specific usage
|
40
|
+
#
|
41
|
+
# Install gemsonrails, add it your Rails app, then freeze quietbacktrace:
|
42
|
+
#
|
43
|
+
# * gem install gemsonrails
|
44
|
+
# * cd rails-app-folder
|
45
|
+
# * gemsonrails
|
46
|
+
# * rake gems:freeze GEM=quietbacktrace
|
47
|
+
#
|
48
|
+
# Quiet Backtrace comes with an excellent Rails-specific silencer and filter.
|
49
|
+
# They must be added (usually in test_helper.rb) because they are not turned on by default:
|
50
|
+
# class Test::Unit::TestCase
|
51
|
+
# self.backtrace_silencers << :rails_vendor
|
52
|
+
# self.backtrace_filters << :rails_root
|
53
|
+
# end
|
54
|
+
#
|
55
|
+
# Because Quiet Backtrace works by adding attributes onto Test::Unit::TestCase,
|
56
|
+
# you can add and remove silencers and filters at any level in your test suite,
|
57
|
+
# down to the individual test.
|
58
|
+
#
|
59
|
+
# == Resources
|
60
|
+
#
|
61
|
+
# * mailing list: http://groups.google.com/group/quiet_backtrace
|
62
|
+
# * project site: http://rubyforge.org/projects/quietbacktrace
|
63
|
+
#
|
64
|
+
# == Authors
|
65
|
+
#
|
66
|
+
# * Dan Croak (dcroak@thoughtbot.com, http://dancroak.com)
|
67
|
+
# * James Golick (james@giraffesoft.ca, http://jamesgolick.com)
|
68
|
+
# * Joe Ferris (jferris@thoughtbot.com)
|
69
|
+
#
|
70
|
+
# Special thanks to the Boston.rb group (http://bostonrb.org)
|
71
|
+
# for cultivating this idea at our inaugural hackfest.
|
72
|
+
#
|
73
|
+
# == Requirements
|
74
|
+
#
|
75
|
+
# * Test::Unit
|
76
|
+
# * aliasing.rb and attribute_accessors.rb, which are snipped from ActiveSupport and
|
77
|
+
# are included in the gem. They allow quiet_backtrace.rb to use alias_method_chain,
|
78
|
+
# cattr_accessor, and mattr_accessor.
|
79
|
+
#
|
80
|
+
# == Copyright
|
81
|
+
#
|
82
|
+
# Copyright (c) 2007 Dan Croak, thoughtbot, inc., released under the MIT license
|
83
|
+
|
84
|
+
require 'test/unit'
|
85
|
+
require File.expand_path(File.dirname(__FILE__) + '/attribute_accessors')
|
86
|
+
require File.expand_path(File.dirname(__FILE__) + '/aliasing')
|
87
|
+
|
88
|
+
module QuietBacktrace # :nodoc: all
|
89
|
+
module BacktraceFilter
|
90
|
+
def self.included(klass)
|
91
|
+
klass.class_eval { alias_method_chain :filter_backtrace, :quieting }
|
92
|
+
end
|
93
|
+
|
94
|
+
mattr_accessor :silencers, :filters
|
95
|
+
self.silencers, self.filters = {}, {}
|
96
|
+
|
97
|
+
def filter_backtrace_with_quieting(backtrace)
|
98
|
+
filter_backtrace_without_quieting(backtrace)
|
99
|
+
|
100
|
+
# Rails view backtraces are flattened into one String. Adjust.
|
101
|
+
backtrace = backtrace.first.split("\n") if backtrace.size == 1
|
102
|
+
|
103
|
+
if Test::Unit::TestCase.quiet_backtrace
|
104
|
+
backtrace.reject! do |line|
|
105
|
+
[*Test::Unit::TestCase.backtrace_silencers].any? do |silencer_name|
|
106
|
+
QuietBacktrace::BacktraceFilter.silencers[silencer_name].call(line) if silencer_name
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
backtrace.each do |line|
|
111
|
+
[*Test::Unit::TestCase.backtrace_filters].each do |filter_name|
|
112
|
+
QuietBacktrace::BacktraceFilter.filters[filter_name].call(line) if filter_name
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
backtrace
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
module TestCase
|
122
|
+
def self.included(klass)
|
123
|
+
klass.class_eval do
|
124
|
+
cattr_accessor :quiet_backtrace, :backtrace_silencers, :backtrace_filters
|
125
|
+
self.backtrace_filters, self.backtrace_silencers = [], []
|
126
|
+
|
127
|
+
extend ClassMethods
|
128
|
+
|
129
|
+
new_backtrace_silencer(:test_unit) do |line|
|
130
|
+
(line.include?("ruby") && line.include?("/test/unit"))
|
131
|
+
end
|
132
|
+
new_backtrace_silencer(:os_x_ruby) do |line|
|
133
|
+
line.include?('Ruby.framework')
|
134
|
+
end
|
135
|
+
new_backtrace_silencer(:gem_root) do |line|
|
136
|
+
line =~ /ruby\/gems/i
|
137
|
+
end
|
138
|
+
new_backtrace_silencer(:e1) do |line|
|
139
|
+
line == "-e:1"
|
140
|
+
end
|
141
|
+
new_backtrace_silencer(:rails_vendor) do |line|
|
142
|
+
(line.include?("vendor/plugins") ||
|
143
|
+
line.include?("vendor/gems") ||
|
144
|
+
line.include?("vendor/rails"))
|
145
|
+
end
|
146
|
+
|
147
|
+
new_backtrace_filter(:method_name) do |line|
|
148
|
+
line.slice!((line =~ /:in /)..line.length) if (line =~ /:in /)
|
149
|
+
end
|
150
|
+
new_backtrace_filter(:rails_root) do |line|
|
151
|
+
line.sub!("#{RAILS_ROOT}/", '') if (defined?(RAILS_ROOT) && line.include?(RAILS_ROOT))
|
152
|
+
end
|
153
|
+
|
154
|
+
self.quiet_backtrace = true
|
155
|
+
self.backtrace_silencers = [:test_unit, :os_x_ruby, :gem_root, :e1]
|
156
|
+
self.backtrace_filters = [:method_name]
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
module ClassMethods
|
161
|
+
def new_backtrace_silencer(symbol, &block)
|
162
|
+
QuietBacktrace::BacktraceFilter.silencers[symbol] = block
|
163
|
+
end
|
164
|
+
|
165
|
+
def new_backtrace_filter(symbol, &block)
|
166
|
+
QuietBacktrace::BacktraceFilter.filters[symbol] = block
|
167
|
+
end
|
168
|
+
end
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
Test::Unit::Util::BacktraceFilter.module_eval { include QuietBacktrace::BacktraceFilter }
|
173
|
+
Test::Unit::TestCase.class_eval { include QuietBacktrace::TestCase }
|
@@ -0,0 +1,11 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = "quietbacktrace"
|
3
|
+
s.version = "1.1.4"
|
4
|
+
s.date = "2008-09-11"
|
5
|
+
s.email = "dcroak@thoughtbot.com"
|
6
|
+
s.homepage = "http://github.com/thoughtbot/quietbacktrace"
|
7
|
+
s.summary = "Quiet Backtrace suppresses the noise in your Test::Unit backtrace."
|
8
|
+
s.description = "Quiet Backtrace suppresses the noise in your Test::Unit backtrace. It also provides hooks for you to add additional silencers and filters."
|
9
|
+
s.files = ["README.markdown", "quietbacktrace.gemspec", "lib/quietbacktrace.rb", "lib/aliasing.rb", "lib/attribute_accessors.rb", "MIT-LICENSE"]
|
10
|
+
s.authors = ["thoughtbot, inc.", "Dan Croak", "James Golick"]
|
11
|
+
end
|
metadata
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: thoughtbot-quietbacktrace
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.1.4
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- thoughtbot, inc.
|
8
|
+
- Dan Croak
|
9
|
+
- James Golick
|
10
|
+
autorequire:
|
11
|
+
bindir: bin
|
12
|
+
cert_chain: []
|
13
|
+
|
14
|
+
date: 2008-09-11 00:00:00 -07:00
|
15
|
+
default_executable:
|
16
|
+
dependencies: []
|
17
|
+
|
18
|
+
description: Quiet Backtrace suppresses the noise in your Test::Unit backtrace. It also provides hooks for you to add additional silencers and filters.
|
19
|
+
email: dcroak@thoughtbot.com
|
20
|
+
executables: []
|
21
|
+
|
22
|
+
extensions: []
|
23
|
+
|
24
|
+
extra_rdoc_files: []
|
25
|
+
|
26
|
+
files:
|
27
|
+
- README.markdown
|
28
|
+
- quietbacktrace.gemspec
|
29
|
+
- lib/quietbacktrace.rb
|
30
|
+
- lib/aliasing.rb
|
31
|
+
- lib/attribute_accessors.rb
|
32
|
+
- MIT-LICENSE
|
33
|
+
has_rdoc: false
|
34
|
+
homepage: http://github.com/thoughtbot/quietbacktrace
|
35
|
+
post_install_message:
|
36
|
+
rdoc_options: []
|
37
|
+
|
38
|
+
require_paths:
|
39
|
+
- lib
|
40
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
41
|
+
requirements:
|
42
|
+
- - ">="
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: "0"
|
45
|
+
version:
|
46
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
47
|
+
requirements:
|
48
|
+
- - ">="
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: "0"
|
51
|
+
version:
|
52
|
+
requirements: []
|
53
|
+
|
54
|
+
rubyforge_project:
|
55
|
+
rubygems_version: 1.2.0
|
56
|
+
signing_key:
|
57
|
+
specification_version: 2
|
58
|
+
summary: Quiet Backtrace suppresses the noise in your Test::Unit backtrace.
|
59
|
+
test_files: []
|
60
|
+
|