Skip to content

Commit

Permalink
very_verbose works in the afternoon
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaron Peckham & Michael Sofaer authored and defunkt committed Mar 17, 2011
1 parent 22970a2 commit 69d5d40
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/resque/worker.rb
Expand Up @@ -489,7 +489,7 @@ def log(message)
if verbose
puts "*** #{message}"
elsif very_verbose
time = Time.now.strftime('%I:%M:%S %Y-%m-%d')
time = Time.now.strftime('%H:%M:%S %Y-%m-%d')
puts "** [#{time}] #$$: #{message}"
end
end
Expand Down
13 changes: 13 additions & 0 deletions test/test_helper.rb
Expand Up @@ -130,3 +130,16 @@ def with_failure_backend(failure_backend, &block)
ensure
Resque::Failure.backend = previous_backend
end

class Time
# Thanks, Timecop
class << self
alias_method :now_without_mock_time, :now

def now_with_mock_time
$fake_time || now_without_mock_time
end

alias_method :now, :now_with_mock_time
end
end
13 changes: 13 additions & 0 deletions test/worker_test.rb
Expand Up @@ -301,6 +301,19 @@
assert $BEFORE_FORK_CALLED
end

test "very verbose works in the afternoon" do
require 'time'
$last_puts = ""
$fake_time = Time.parse("15:44:33 2011-03-02")
singleton = class << @worker; self end
singleton.send :define_method, :puts, lambda { |thing| $last_puts = thing }

@worker.very_verbose = true
@worker.log("some log text")

assert_match /\*\* \[15:44:33 2011-03-02\] \d+: some log text/, $last_puts
end

test "Will call an after_fork hook after forking" do
Resque.redis.flushall
$AFTER_FORK_CALLED = false
Expand Down

0 comments on commit 69d5d40

Please sign in to comment.