Sha256: a79d2b1f8023e81debef16df7b756803607b00fbdc5b3c554b551ae3426238eb

Contents?: true

Size: 1.86 KB

Versions: 1

Compression:

Stored size: 1.86 KB

Contents

module FormatterSupport

  def send_notification type, notification
    reporter.notify type, notification
  end

  def reporter
    @reporter ||= setup_reporter
  end

  def setup_reporter(*streams)
    config.add_formatter described_class, *streams
    @formatter = config.formatters.first
    @reporter = config.reporter
  end

  def output
    @output ||= StringIO.new
  end

  def config
    @configuration ||=
      begin
        config = RSpec::Core::Configuration.new
        config.output_stream = output
        config
      end
  end

  def configure
    yield config
  end

  def formatter
    @formatter ||=
      begin
        setup_reporter
        @formatter
      end
  end

  def example
    instance_double("RSpec::Core::Example",
                    :description      => "Example",
                    :full_description => "Example",
                    :execution_result => { :exception => Exception.new },
                    :metadata         => {}
                   )
  end

  def group
    class_double "RSpec::Core::ExampleGroup", :description => "Group"
  end

  def start_notification(count)
   ::RSpec::Core::Notifications::StartNotification.new count
  end

  def example_notification(specific_example = example)
   ::RSpec::Core::Notifications::ExampleNotification.new specific_example
  end

  def group_notification
   ::RSpec::Core::Notifications::GroupNotification.new group
  end

  def message_notification(message)
    ::RSpec::Core::Notifications::MessageNotification.new message
  end

  def null_notification
    ::RSpec::Core::Notifications::NullNotification
  end

  def seed_notification(seed, used = true)
    ::RSpec::Core::Notifications::SeedNotification.new seed, used
  end

  def summary_notification(duration, examples, failed, pending, time)
    ::RSpec::Core::Notifications::SummaryNotification.new duration, examples, failed, pending, time
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rspec-legacy_formatters-1.0.0.rc1 spec/support/formatter_support.rb