Permalink
Browse files

fix simple syslog tests

  • Loading branch information...
1 parent e49f077 commit d8ccf86984b6fd8d8031d31995eefe76b5ecd1ff @antonlindstrom committed Sep 26, 2012
Showing with 28 additions and 2 deletions.
  1. +2 −2 lib/backup/logger.rb
  2. +26 −0 spec/logger_spec.rb
View
@@ -20,7 +20,7 @@ def message(string)
def error(string)
to_console loggify(string, :error, :red), true
to_file loggify(string, :error)
- to_syslog loggify(string), :err
+ to_syslog loggify(string, :error), :err
end
##
@@ -30,7 +30,7 @@ def warn(string)
@has_warnings = true
to_console loggify(string, :warning, :yellow), true
to_file loggify(string, :warning)
- to_syslog loggify(string), :warn
+ to_syslog loggify(string, :warning), :warn
end
# Outputs the data as if it were a regular 'puts' command,
View
@@ -33,6 +33,11 @@
returns(:uncolored_regular_message)
subject.expects(:to_file).in_sequence(s).
with(:uncolored_regular_message)
+ subject.expects(:loggify).in_sequence(s).
+ with('regular message', :message).
+ returns(:uncolored_regular_message)
+ subject.expects(:to_syslog).in_sequence(s).
+ with(:uncolored_regular_message)
subject.message('regular message')
end
@@ -50,6 +55,11 @@
returns(:uncolored_error_message)
subject.expects(:to_file).in_sequence(s).
with(:uncolored_error_message)
+ subject.expects(:loggify).in_sequence(s).
+ with('error message', :error).
+ returns(:uncolored_error_message)
+ subject.expects(:to_syslog).in_sequence(s).
+ with(:uncolored_error_message, :err)
subject.error('error message')
end
@@ -67,13 +77,19 @@
returns(:uncolored_warning_message)
subject.expects(:to_file).in_sequence(s).
with(:uncolored_warning_message)
+ subject.expects(:loggify).in_sequence(s).
+ with('warning message', :warning).
+ returns(:uncolored_warning_message)
+ subject.expects(:to_syslog).in_sequence(s).
+ with(:uncolored_warning_message, :warn)
subject.warn('warning message')
end
it 'sets has_warnings? to true' do
subject.stubs(:to_console)
subject.stubs(:to_file)
+ subject.stubs(:to_syslog)
expect { subject.warn('warning') }.
to change{ subject.has_warnings? }.from(false).to(true)
end
@@ -91,6 +107,11 @@
returns(:unformatted_message)
subject.expects(:to_file).in_sequence(s).
with(:unformatted_message)
+ subject.expects(:loggify).in_sequence(s).
+ with('normal message').
+ returns(:unformatted_message)
+ subject.expects(:to_syslog).in_sequence(s).
+ with(:unformatted_message)
subject.normal('normal message')
end
@@ -104,6 +125,11 @@
returns(:silent_message)
subject.expects(:to_file).in_sequence(s).
with(:silent_message)
+ subject.expects(:loggify).in_sequence(s).
+ with('silent message', :silent).
+ returns(:silent_message)
+ subject.expects(:to_syslog).in_sequence(s).
+ with(:silent_message)
subject.silent('silent message')
end

0 comments on commit d8ccf86

Please sign in to comment.