Sha256: 272ce67fcdd7401251f88fed043d21a5aa1c22b8602da3019d4261c8a89f0079
Contents?: true
Size: 1.28 KB
Versions: 4
Compression:
Stored size: 1.28 KB
Contents
module Jasmine module Formatters class Console def initialize(outputter = Kernel.method(:puts)) @results = [] @outputter = outputter end def format(results_batch) outputter.call(failures(results_batch)) @results += results_batch end def done failure_count = results.count(&:failed?) pending_count = results.count(&:pending?) summary = "#{pluralize(results.size, 'spec')}, " + "#{pluralize(failure_count, 'failure')}" summary += ", #{pluralize(pending_count, 'pending spec')}" if pending_count > 0 outputter.call(summary) end private attr_reader :results, :outputter def failures(results) results.select(&:failed?).map { |f| failure_message(f) }.join("\n\n") end def pluralize(count, str) word = (count == 1) ? str : str + 's' "#{count} #{word}" end def failure_message(failure) template = <<-FM #{failure.full_name}\n FM template += failure.failed_expectations.map { |fe| expectation_message(fe) }.join("\n") end def expectation_message(expectation) <<-FE #{expectation.message} #{expectation.stack} FE end end end end
Version data entries
4 entries across 4 versions & 1 rubygems