Sha256: a08bc27f1cb0d38ee397ea1961dd46d0b55bd327fc59a6947c5dcf8ce3071e18

Contents?: true

Size: 1.31 KB

Versions: 2

Compression:

Stored size: 1.31 KB

Contents

require 'spec_helper'
require 'shared/configured'

describe MetricFu::Configuration, 'for formatters' do
  it_behaves_like 'configured' do

    describe '#configure_formatter' do
      before(:each) { get_new_config }

      context 'given a built-in formatter' do
        before do
          @config.configure_formatter('html')
        end

        it 'adds to the list of formatters' do
          expect(@config.formatters.first).to be_an_instance_of(MetricFu::Formatter::HTML)
        end
      end

      context 'given a custom formatter by class name' do
        before do
          stub_const('MyCustomFormatter', Class.new() { def initialize(*); end })
          @config.configure_formatter('MyCustomFormatter')
        end

        it 'adds to the list of formatters' do
          expect(@config.formatters.first).to be_an_instance_of(MyCustomFormatter)
        end
      end

      context 'given multiple formatters' do
        before do
          stub_const('MyCustomFormatter', Class.new() { def initialize(*); end })
          @config.configure_formatter('html')
          @config.configure_formatter('yaml')
          @config.configure_formatter('MyCustomFormatter')
        end

        it 'adds each to the list of formatters' do
          expect(@config.formatters.count).to eq(3)
        end
      end
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
metric_fu-4.11.1 spec/metric_fu/formatter/configuration_spec.rb
metric_fu-4.11.0 spec/metric_fu/formatter/configuration_spec.rb