Sha256: 014b2f214eb7b707531b3cb1052fa2bac30d85e49099eacee9955712ec50272c

Contents?: true

Size: 971 Bytes

Versions: 12

Compression:

Stored size: 971 Bytes

Contents

# encoding: utf-8

require 'spec_helper'
require "zabbix-ruby-client/logger"

describe ZabbixRubyClient::Log do

  before :all do
    @logfile = File.expand_path("../../files/logs/testlog", __FILE__)
  end

  after :each do
    File.unlink(@logfile) if File.exists?(@logfile)
  end

  it "set_logger prepares the logger" do
    ZabbixRubyClient::Log.set_logger(@logfile, 'info')
    expect(ZabbixRubyClient::Log.instance_variable_get(:@logger)).to be_instance_of Logger
    expect(ZabbixRubyClient::Log.logger.level).to be Logger::INFO
  end

  it "logged message are nicely formatted" do
    ZabbixRubyClient::Log.set_logger(@logfile, 'debug')
    ZabbixRubyClient::Log.logger.debug("ha")
    expect(File.read(@logfile)).to match /\] DEBUG: ha\n/
  end

  it "loglevel is properly interpreted from argument" do
    ZabbixRubyClient::Log.set_logger(@logfile, 'debug')
    expect(ZabbixRubyClient::Log.instance_variable_get(:@logger).level).to be Logger::DEBUG
  end

end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
zabbix-ruby-client-0.1.3 spec/lib/logger_spec.rb
zabbix-ruby-client-0.1.2 spec/lib/logger_spec.rb
zabbix-ruby-client-0.1.1 spec/lib/logger_spec.rb
zabbix-ruby-client-0.1.0 spec/lib/logger_spec.rb
zabbix-ruby-client-0.0.23 spec/lib/logger_spec.rb
zabbix-ruby-client-0.0.22 spec/lib/logger_spec.rb
zabbix-ruby-client-0.0.21 spec/lib/logger_spec.rb
zabbix-ruby-client-0.0.20 spec/lib/logger_spec.rb
zabbix-ruby-client-0.0.19 spec/lib/logger_spec.rb
zabbix-ruby-client-0.0.18 spec/lib/logger_spec.rb
zabbix-ruby-client-0.0.17 spec/lib/logger_spec.rb
zabbix-ruby-client-0.0.16 spec/lib/logger_spec.rb