Sha256: e1f4e3e4b3d85a2ed6eb90772ca75d0011c368ababf172f3d19a95cb6d2d7845
Contents?: true
Size: 1.37 KB
Versions: 13
Compression:
Stored size: 1.37 KB
Contents
# encoding: utf-8 require File.dirname(__FILE__) + '/spec_helper' require 'timecop' describe Backup::Logger do before do Timecop.freeze( Time.now ) end context 'when logging regular messages' do it do Backup::Logger.expects(:puts).with("[#{ Time.now.strftime("%Y/%m/%d %H:%M:%S") }][\e[32mmessage\e[0m] This has been logged.") File.expects(:open).with(File.join(Backup::LOG_PATH, 'backup.log'), 'a') Backup::Logger.message "This has been logged." end end context 'when logging error messages' do it do Backup::Logger.expects(:puts).with("[#{ Time.now.strftime("%Y/%m/%d %H:%M:%S") }][\e[31merror\e[0m] This has been logged.") File.expects(:open).with(File.join(Backup::LOG_PATH, 'backup.log'), 'a') Backup::Logger.error "This has been logged." end end context 'when logging warn messages' do it do Backup::Logger.expects(:puts).with("[#{ Time.now.strftime("%Y/%m/%d %H:%M:%S") }][\e[33mwarning\e[0m] This has been logged.") File.expects(:open).with(File.join(Backup::LOG_PATH, 'backup.log'), 'a') Backup::Logger.warn "This has been logged." end end context 'when logging silent messages' do it do Backup::Logger.expects(:puts).never File.expects(:open).with(File.join(Backup::LOG_PATH, 'backup.log'), 'a') Backup::Logger.silent "This has been logged." end end end
Version data entries
13 entries across 13 versions & 2 rubygems