Class: XSpec::Notifier::FailuresAtEnd
- Inherits:
-
Object
- Object
- XSpec::Notifier::FailuresAtEnd
- Includes:
- Composable
- Defined in:
- lib/xspec/notifiers.rb
Overview
Outputs error messages and backtraces after the entire run is complete.
Instance Method Summary collapse
-
#clean_backtrace(backtrace) ⇒ Object
A standard backtrace contains many entries for XSpec itself which are not useful for debugging your tests, so they are stripped out.
- #evaluate_finish(result) ⇒ Object
- #evaluate_start(*_) ⇒ Object
- #full_name(unit_of_work) ⇒ Object
-
#initialize(out = $stdout) ⇒ FailuresAtEnd
constructor
A new instance of FailuresAtEnd.
- #run_finish ⇒ Object
- #run_start ⇒ Object
Methods included from Composable
Constructor Details
#initialize(out = $stdout) ⇒ FailuresAtEnd
Returns a new instance of FailuresAtEnd.
153 154 155 156 |
# File 'lib/xspec/notifiers.rb', line 153 def initialize(out = $stdout) @errors = [] @out = out end |
Instance Method Details
#clean_backtrace(backtrace) ⇒ Object
A standard backtrace contains many entries for XSpec itself which are not useful for debugging your tests, so they are stripped out.
187 188 189 190 191 192 193 |
# File 'lib/xspec/notifiers.rb', line 187 def clean_backtrace(backtrace) lib_dir = File.dirname(File.('..', __FILE__)) backtrace.reject {|x| File.dirname(x).start_with?(lib_dir) } end |
#evaluate_finish(result) ⇒ Object
162 163 164 |
# File 'lib/xspec/notifiers.rb', line 162 def evaluate_finish(result) self.errors += result.errors end |
#evaluate_start(*_) ⇒ Object
160 |
# File 'lib/xspec/notifiers.rb', line 160 def evaluate_start(*_); end |
#full_name(unit_of_work) ⇒ Object
181 182 183 |
# File 'lib/xspec/notifiers.rb', line 181 def full_name(unit_of_work) (unit_of_work.parents + [unit_of_work]).map(&:name).compact.join(' ') end |
#run_finish ⇒ Object
166 167 168 169 170 171 172 173 174 175 176 177 178 179 |
# File 'lib/xspec/notifiers.rb', line 166 def run_finish return true if errors.empty? out.puts errors.each do |error| out.puts "%s:\n%s\n\n" % [full_name(error.unit_of_work), error..lines.map {|x| " #{x}"}.join("")] clean_backtrace(error.caller).each do |line| out.puts " %s" % line end out.puts end false end |
#run_start ⇒ Object
158 |
# File 'lib/xspec/notifiers.rb', line 158 def run_start; end |