waterlink / spec2.cr

Enhanced `spec` testing library for [Crystal](http://crystal-lang.org/).
MIT License
103 stars 22 forks source link

Feature request: Accept multiple reporters #23

Open marceloboeira opened 8 years ago

marceloboeira commented 8 years ago

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.

waterlink commented 7 years ago

@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