waterlink/spec2.cr

Feature request: Accept multiple reporters

marceloboeira opened this issue · 1 comments

Like rspec, (rspec/rspec-core#47), spec2 could support multiple reporters/formatters, in order to make possible to use several outputs.

I'm currently working on a way to send OSX notifications, like rspec-nc for spec2, so that would help me a lot.

@marceloboeira By the way, if one uses Composite pattern, it is possible to make multiple reporters work without the modification of the library. Here is the concept:

class CompositeReporter < ::Spec2::Reporter

  def initialize(@list : Array(::Spec2::Reporter)); end

  def configure_output(output) @list.each &.configure_output(output); end
  def context_started(context) @list.each &.context_started(context); end
  def context_finished(context) @list.each &.context_finished(context); end
  def example_started(example) @list.each &.example_started(example); end
  def example_succeeded(example) @list.each &.example_succeeded(example); end
  def example_failed(example, exception) @list.each &.example_failed(example, exception); end
  def example_errored(example, exception) @list.each &.example_errored(example, exception); end
  def report; @list.each &.report; end
end