test/clockwork_test.rb in clockwork-1.2.0 vs test/clockwork_test.rb in clockwork-1.2.1

- old
+ new

@@ -1,35 +1,36 @@ require File.expand_path('../../lib/clockwork', __FILE__) -require 'test/unit' +require 'minitest/autorun' require 'mocha/setup' -class ClockworkTest < Test::Unit::TestCase - setup do +describe Clockwork do + before do @log_output = StringIO.new Clockwork.configure do |config| config[:sleep_timeout] = 0 config[:logger] = Logger.new(@log_output) end end - teardown do + after do Clockwork.clear! end - test 'should run events with configured logger' do + it 'should run events with configured logger' do run = false Clockwork.handler do |job| run = job == 'myjob' end Clockwork.every(1.minute, 'myjob') Clockwork.manager.expects(:loop).yields.then.returns Clockwork.run + assert run assert @log_output.string.include?('Triggering') end - test 'should log event correctly' do + it 'should log event correctly' do run = false Clockwork.handler do |job| run = job == 'an event' end Clockwork.every(1.minute, 'an event') @@ -37,11 +38,11 @@ Clockwork.run assert run assert @log_output.string.include?("Triggering 'an event'") end - test 'should pass event without modification to handler' do + it 'should pass event without modification to handler' do event_object = Object.new run = false Clockwork.handler do |job| run = job == event_object end @@ -49,11 +50,11 @@ Clockwork.manager.expects(:loop).yields.then.returns Clockwork.run assert run end - test 'should not run anything after reset' do + it 'should not run anything after reset' do Clockwork.every(1.minute, 'myjob') { } Clockwork.clear! Clockwork.configure do |config| config[:sleep_timeout] = 0 config[:logger] = Logger.new(@log_output) @@ -61,18 +62,18 @@ Clockwork.manager.expects(:loop).yields.then.returns Clockwork.run assert @log_output.string.include?('0 events') end - test 'should pass all arguments to every' do + it 'should pass all arguments to every' do Clockwork.every(1.second, 'myjob', if: lambda { |_| false }) { } Clockwork.manager.expects(:loop).yields.then.returns Clockwork.run assert @log_output.string.include?('1 events') assert !@log_output.string.include?('Triggering') end - test 'support module re-open style' do + 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