Sha256: 81b00e56c7a44a77e7cb5171fc86a6c0b859c6b965ede20ff8d00b33989b5c41

Contents?: true

Size: 1.12 KB

Versions: 10

Compression:

Stored size: 1.12 KB

Contents

require "spec_helper"
MetricFu.lib_require { 'reporter' }

describe MetricFu::Reporter do

  context 'given a single formatter' do
    before do
      @formatter = double('formatter')
      allow(@formatter).to receive(:to_a).and_return([@formatter])
      @reporter = Reporter.new(@formatter)
    end

    it 'notifies the formatter' do
      expect(@formatter).to receive(:start)
      expect(@formatter).to receive(:finish)
      @reporter.start
      @reporter.finish
    end

    it 'only sends notifications when supported by formatter' do
      allow(@formatter).to receive(:respond_to?).with(:display_results).and_return(false)
      expect(@formatter).not_to receive(:display_results)
      @reporter.display_results
    end
  end

  context 'given multiple formatters' do
    before do
      @formatters = [double('formatter'), double('formatter')]
      @reporter = Reporter.new(@formatters)
    end

    it 'notifies all formatters' do
      @formatters.each do |formatter|
        expect(formatter).to receive(:start)
        expect(formatter).to receive(:finish)
      end
      @reporter.start
      @reporter.finish
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
metric_fu-4.11.1 spec/metric_fu/reporter_spec.rb
metric_fu-4.11.0 spec/metric_fu/reporter_spec.rb
metric_fu-4.10.0 spec/metric_fu/reporter_spec.rb
metric_fu-4.9.0 spec/metric_fu/reporter_spec.rb
metric_fu-4.8.0 spec/metric_fu/reporter_spec.rb
metric_fu-4.7.4 spec/metric_fu/reporter_spec.rb
metric_fu-4.7.3 spec/metric_fu/reporter_spec.rb
metric_fu-4.7.2 spec/metric_fu/reporter_spec.rb
metric_fu-4.7.1 spec/metric_fu/reporter_spec.rb
metric_fu-4.7.0 spec/metric_fu/reporter_spec.rb