File tree Expand file tree Collapse file tree 2 files changed +20
-12
lines changed Expand file tree Collapse file tree 2 files changed +20
-12
lines changed Original file line number Diff line number Diff line change @@ -147,12 +147,14 @@ def with_failure_backend(failure_backend, &block)
147
147
class Time
148
148
# Thanks, Timecop
149
149
class << self
150
+ attr_accessor :fake_time
151
+
150
152
alias_method :now_without_mock_time , :now
151
153
152
- def now_with_mock_time
153
- $ fake_time || now_without_mock_time
154
+ def now
155
+ fake_time || now_without_mock_time
154
156
end
155
-
156
- alias_method :now , :now_with_mock_time
157
157
end
158
+
159
+ self . fake_time = nil
158
160
end
Original file line number Diff line number Diff line change @@ -355,16 +355,22 @@ def self.exception
355
355
end
356
356
357
357
test "very verbose works in the afternoon" do
358
- require 'time'
359
- $last_puts = ""
360
- $fake_time = Time . parse ( "15:44:33 2011-03-02" )
361
- singleton = class << @worker ; self end
362
- singleton . send :define_method , :puts , lambda { |thing | $last_puts = thing }
358
+ begin
359
+ require 'time'
360
+ last_puts = ""
361
+ Time . fake_time = Time . parse ( "15:44:33 2011-03-02" )
363
362
364
- @worker . very_verbose = true
365
- @worker . log ( "some log text" )
363
+ @worker . extend ( Module . new {
364
+ define_method ( :puts ) { |thing | last_puts = thing }
365
+ } )
366
366
367
- assert_match /\* \* \[ 15:44:33 2011-03-02\] \d +: some log text/ , $last_puts
367
+ @worker . very_verbose = true
368
+ @worker . log ( "some log text" )
369
+
370
+ assert_match /\* \* \[ 15:44:33 2011-03-02\] \d +: some log text/ , last_puts
371
+ ensure
372
+ Time . fake_time = nil
373
+ end
368
374
end
369
375
370
376
test "Will call an after_fork hook after forking" do
You can’t perform that action at this time.
0 commit comments