spec/lib/logger_spec.rb in zabbix-ruby-client-0.0.15 vs spec/lib/logger_spec.rb in zabbix-ruby-client-0.0.16
- old
+ new
@@ -1,12 +1,33 @@
# encoding: utf-8
require 'spec_helper'
require "zabbix-ruby-client/logger"
-describe ZabbixRubyClient::Logger do
+describe ZabbixRubyClient::Log do
- pending "get_logger returns a valid Logger instance"
- pending "logged message are nicely formatted"
- pending "loglevel is properly interpreted from argument"
+ before :all do
+ @logfile = File.expand_path("../../files/logs/testlog", __FILE__)
+ end
-end
\ No newline at end of file
+ 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