Sha256: 17d4ecd5287093fa812a04593eb9843a306707c81d1f99448eb5d819c5657f4d

Contents?: true

Size: 1.31 KB

Versions: 7

Compression:

Stored size: 1.31 KB

Contents

# -*- ruby -*-
# vim: set nosta noet ts=4 sw=4:
# frozen_string_literal: true

require_relative '../helpers'

require 'loggability/formatter'


describe Loggability::Formatter do

	before( :all ) do
		@actual_derivatives = described_class.derivatives.dup
	end

	after( :all ) do
		described_class.derivatives.replace( @actual_derivatives )
	end


	describe "concrete subclasses" do

		class Test < described_class
		end


		it "must implement #call" do
			expect {
				Test.new.call( 'INFO', Time.now, nil, "A message." )
			}.to raise_error( /doesn't implement required method/i )
		end


		it "is tracked by the base class" do
			expect( described_class.derivatives ).to include( test: Test )
		end


		it "is tracked if its anonymous" do
			subclass = Class.new( described_class )
			expect( described_class.derivatives.values ).to include( subclass )
		end


		it "can be loaded by name" do
			expect( described_class ).to receive( :require ).
				with( "loggability/formatter/test" )

			expect( described_class.create(:test) ).to be_an_instance_of( Test )
		end


		it "raises a LoadError if loading doesn't work" do
			expect( described_class ).to receive( :require ).
				with( "loggability/formatter/circus" )

			expect {
				described_class.create( :circus )
			}.to raise_error( LoadError, /didn't load a class/i )
		end


	end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
loggability-0.18.2 spec/loggability/formatter_spec.rb
loggability-0.18.1 spec/loggability/formatter_spec.rb
loggability-0.18.0 spec/loggability/formatter_spec.rb
loggability-0.17.0 spec/loggability/formatter_spec.rb
loggability-0.16.0 spec/loggability/formatter_spec.rb
loggability-0.15.1 spec/loggability/formatter_spec.rb
loggability-0.15.0.pre20190714094638 spec/loggability/formatter_spec.rb