Sha256: cdc533ce519b71935c248d901f76aaafd5b0220e70be40477ab190418694bb59

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.3 spec/metric_fu/formatter/configuration_spec.rb
metric_fu-4.11.2 spec/metric_fu/formatter/configuration_spec.rb