Sha256: 7bf5e7034a0388fb034ea14f804ba91a3227486d3712d4318fca1b85ef123d36

Contents?: true

Size: 1.65 KB

Versions: 4

Compression:

Stored size: 1.65 KB

Contents

require 'assert'
require 'ostruct'
require 'syslog'
require 'logging'
require 'logsly/settings'
require 'logsly/syslog_output'

class Logsly::SyslogOutput

  class DataTests < Assert::Context
    desc "the FileOutputData handler"
    setup do
      @data = Logsly::SyslogOutputData.new {}
    end
    subject { @data }

    should have_imeth :identity, :log_opts, :facility

    should "default :log_opts" do
      assert_equal (Syslog::LOG_PID | Syslog::LOG_CONS), subject.log_opts
    end

    should "default :facility" do
      assert_equal Syslog::LOG_LOCAL0, subject.facility
    end

  end

  class BaseTests < Assert::Context
    desc "the SyslogOutput handler"
    setup do
      @logger = OpenStruct.new
      @logger.debug_level = :white
      @logger.pattern  = '%d : %m\n'
      @logger.identity = "whatever"
      @logger.facility = Syslog::LOG_LOCAL3

      Logsly.colors('a_color_scheme') do |logger|
        debug logger.debug_level
      end

      @out = Logsly::SyslogOutput.new do |logger|
        identity logger.identity
        facility logger.facility

        pattern logger.pattern
        colors  'a_color_scheme'
      end
    end
    subject { @out }

    should "be an output handler" do
      assert_kind_of Logsly::BaseOutput, subject
    end

    should "build a Logging syslog appender, passing args to the builds" do
      appender = subject.to_appender @logger

      assert_kind_of Logging::Appenders::Syslog, appender
      assert_kind_of Logging::Layouts::Pattern,  appender.layout
      assert_equal   '%d : %m\n',                appender.layout.pattern
      assert_kind_of Logging::ColorScheme,       appender.layout.color_scheme
    end
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
logsly-1.0.2 test/unit/syslog_output_tests.rb
logsly-1.0.1 test/unit/syslog_output_tests.rb
logsly-1.0.0 test/unit/syslog_output_tests.rb
logsly-1.0.0.rc1 test/unit/syslog_output_tests.rb