test/clockwork_test.rb in clockwork-2.0.0 vs test/clockwork_test.rb in clockwork-2.0.1
- old
+ new
@@ -7,10 +7,11 @@
@log_output = StringIO.new
Clockwork.configure do |config|
config[:sleep_timeout] = 0
config[:logger] = Logger.new(@log_output)
end
+ IO.stubs(:select)
end
after do
Clockwork.clear!
end
@@ -19,11 +20,11 @@
run = false
Clockwork.handler do |job|
run = job == 'myjob'
end
Clockwork.every(1.minute, 'myjob')
- Clockwork.manager.expects(:loop).yields.then.returns
+ Clockwork.manager.stubs(:run_tick_loop).returns(Clockwork.manager.tick)
Clockwork.run
assert run
assert @log_output.string.include?('Triggering')
end
@@ -32,11 +33,11 @@
run = false
Clockwork.handler do |job|
run = job == 'an event'
end
Clockwork.every(1.minute, 'an event')
- Clockwork.manager.expects(:loop).yields.then.returns
+ Clockwork.manager.stubs(:run_tick_loop).returns(Clockwork.manager.tick)
Clockwork.run
assert run
assert @log_output.string.include?("Triggering 'an event'")
end
@@ -45,11 +46,11 @@
run = false
Clockwork.handler do |job|
run = job == event_object
end
Clockwork.every(1.minute, event_object)
- Clockwork.manager.expects(:loop).yields.then.returns
+ Clockwork.manager.stubs(:run_tick_loop).returns(Clockwork.manager.tick)
Clockwork.run
assert run
end
it 'should not run anything after reset' do
@@ -57,28 +58,28 @@
Clockwork.clear!
Clockwork.configure do |config|
config[:sleep_timeout] = 0
config[:logger] = Logger.new(@log_output)
end
- Clockwork.manager.expects(:loop).yields.then.returns
+ Clockwork.manager.stubs(:run_tick_loop).returns(Clockwork.manager.tick)
Clockwork.run
assert @log_output.string.include?('0 events')
end
it 'should pass all arguments to every' do
Clockwork.every(1.second, 'myjob', if: lambda { |_| false }) { }
- Clockwork.manager.expects(:loop).yields.then.returns
+ Clockwork.manager.stubs(:run_tick_loop).returns(Clockwork.manager.tick)
Clockwork.run
assert @log_output.string.include?('1 events')
assert !@log_output.string.include?('Triggering')
end
it 'support module re-open style' do
$called = false
module ::Clockwork
every(1.second, 'myjob') { $called = true }
end
- Clockwork.manager.expects(:loop).yields.then.returns
+ Clockwork.manager.stubs(:run_tick_loop).returns(Clockwork.manager.tick)
Clockwork.run
assert $called
end
end