ref: master
test/unit/feed_updater_test.rb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
require_relative "../test_helper" class FeedUpdaterTest < ActiveSupport::TestCase should 'be running by default' do assert_equal true, FeedUpdater.new.running end should 'unset running when stopped' do updater = FeedUpdater.new updater.expects(:running=).with(false) updater.stop end should 'sleep in intervals of one second' do FeedUpdater.stubs(:daemon_sleep_interval).returns(30) updater = FeedUpdater.new updater.expects(:sleep).with(1).times(30) updater.wait end should 'not sleep when stopped' do FeedUpdater.stubs(:daemon_sleep_interval).returns(30) updater = FeedUpdater.new updater.stubs(:running).returns(true).then.returns(true).then.returns(false) updater.expects(:sleep).with(1).times(2) updater.wait end should 'process until it is stopped' do updater = FeedUpdater.new updater.stubs(:running).returns(true).then.returns(true).then.returns(false) updater.expects(:process_round).times(2) updater.expects(:wait).times(2) updater.run end end |