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

Version Path
backup-3.0.14 spec/logger_spec.rb
backup-3.0.13 spec/logger_spec.rb
backup-3.0.12 spec/logger_spec.rb
backup-3.0.11 spec/logger_spec.rb
alg-backup-3.0.10 spec/logger_spec.rb
backup-3.0.10 spec/logger_spec.rb
backup-3.0.9 spec/logger_spec.rb
backup-3.0.8 spec/logger_spec.rb
backup-3.0.7 spec/logger_spec.rb
backup-3.0.6 spec/logger_spec.rb
backup-3.0.5 spec/logger_spec.rb
backup-3.0.4 spec/logger_spec.rb
backup-3.0.3 spec/logger_spec.rb