Sha256: bf43e390808687d3d49d956bb664ab800f3257ba0d7aa47a45da614cfae6d965
Contents?: true
Size: 1.09 KB
Versions: 2
Compression:
Stored size: 1.09 KB
Contents
class MockLogger attr_accessor :messages, :errors def self.configure_log(name, config = {}) @name = name end def initialize @messages = [] @errors = [] end def clear @messages.clear @errors.clear end %w(debug info warn).each do |level| class_eval <<-RUBY def #{level}(msg = nil, &block) msg = yield if msg.nil? && block_given? @messages << '[#{level.upcase}] :: ' + (self.class.instance_variable_get('@name') || 'flapjack') + ' :: ' + msg end RUBY end %w(error fatal).each do |level| class_eval <<-ERRORS def #{level}(msg = nil, &block) msg = yield if msg.nil? && block_given? @messages << '[#{level.upcase}] :: ' + (self.class.instance_variable_get('@name') || 'flapjack') + ' :: ' + msg @errors << '[#{level.upcase}] :: ' + (self.class.instance_variable_get('@name') || 'flapjack') + ' :: ' + msg end ERRORS end %w(debug info warn error fatal).each do |level| class_eval <<-LEVELS def #{level}? true end LEVELS end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
zermelo-1.2.1 | spec/support/mock_logger.rb |
zermelo-1.2.0 | spec/support/mock_logger.rb |