Class: XSpec::Notifier::FailuresAtEnd

Inherits:
Object
  • Object
show all
Includes:
Composable, EmptyFormatter, ShortIdSupport
Defined in:
lib/xspec/notifiers.rb

Overview

Outputs error messages and backtraces after the entire run is complete.

Instance Method Summary collapse

Methods included from ShortIdSupport

#run_start, #short_id_for

Methods included from Composable

#+

Methods included from EmptyFormatter

#evaluate_start, #run_start

Constructor Details

#initialize(out = $stdout) ⇒ FailuresAtEnd

Returns a new instance of FailuresAtEnd.



172
173
174
175
# File 'lib/xspec/notifiers.rb', line 172

def initialize(out = $stdout)
  @errors = []
  @out    = out
end

Instance Method Details

#evaluate_finish(result) ⇒ Object



177
178
179
# File 'lib/xspec/notifiers.rb', line 177

def evaluate_finish(result)
  self.errors += result.errors
end

#run_finishObject



181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
# File 'lib/xspec/notifiers.rb', line 181

def run_finish
  return true if errors.empty?

  out.puts
  errors.each do |error|
    out.puts "%s - %s\n%s\n\n" % [
      short_id_for(error.unit_of_work),
      error.unit_of_work.full_name,
      error.message.lines.map {|x| "  #{x}"}.join("")
    ]
    clean_backtrace(error.caller).each do |line|
      out.puts "  %s" % line
    end
    out.puts
  end

  false
end