|
1 | | -require 'test/unit' |
| 1 | +require "minitest/autorun" |
2 | 2 | require 'mocha/minitest' |
3 | 3 | require 'fileutils' |
4 | 4 |
|
5 | | -class SignalTest < Test::Unit::TestCase |
6 | | - CMD = File.expand_path('../../bin/clockwork', __FILE__) |
7 | | - SAMPLE = File.expand_path('../samples/signal_test.rb', __FILE__) |
8 | | - LOGFILE = File.expand_path('../tmp/signal_test.log', __FILE__) |
9 | | - |
10 | | - setup do |
11 | | - FileUtils.mkdir_p(File.dirname(LOGFILE)) |
12 | | - @pid = spawn(CMD, SAMPLE) |
13 | | - until File.exist?(LOGFILE) |
| 5 | +describe "SignalTest" do |
| 6 | + before do |
| 7 | + @command = File.expand_path('../../bin/clockwork', __FILE__) |
| 8 | + @sample = File.expand_path('../samples/signal_test.rb', __FILE__) |
| 9 | + @logfile = File.expand_path('../tmp/signal_test.log', __FILE__) |
| 10 | + FileUtils.mkdir_p(File.dirname(@logfile)) |
| 11 | + @pid = spawn(@command, @sample) |
| 12 | + until File.exist?(@logfile) |
14 | 13 | sleep 0.1 |
15 | 14 | end |
16 | 15 | end |
17 | 16 |
|
18 | | - teardown do |
19 | | - FileUtils.rm_r(File.dirname(LOGFILE)) |
| 17 | + after do |
| 18 | + FileUtils.rm_r(File.dirname(@logfile)) |
20 | 19 | end |
21 | 20 |
|
22 | | - test 'should gracefully shutdown with SIGTERM' do |
| 21 | + it 'should gracefully shutdown with SIGTERM' do |
23 | 22 | Process.kill(:TERM, @pid) |
24 | 23 | sleep 0.2 |
25 | | - assert_equal 'done', File.read(LOGFILE) |
| 24 | + assert_equal 'done', File.read(@logfile) |
26 | 25 | end |
27 | 26 |
|
28 | | - test 'should forcely shutdown with SIGINT' do |
| 27 | + it 'should forcely shutdown with SIGINT' do |
29 | 28 | Process.kill(:INT, @pid) |
30 | 29 | sleep 0.2 |
31 | | - assert_equal 'start', File.read(LOGFILE) |
| 30 | + assert_equal 'start', File.read(@logfile) |
32 | 31 | end |
33 | 32 | end |
34 | | - |
0 commit comments