spec/sqewer/cli_spec.rb in sqewer-1.0.0 vs spec/sqewer/cli_spec.rb in sqewer-2.0.0
- old
+ new
@@ -4,22 +4,24 @@
describe 'runs the commandline app, executes jobs and then quits cleanly' do
it 'on a USR1 signal' do
submitter = Sqewer::Connection.default
stderr = Tempfile.new('worker-stderr')
-
+ stderr.sync = true
+
pid = fork { $stderr.reopen(stderr); exec("ruby #{__dir__}/cli_app.rb") }
Thread.new do
20.times do
j = {job_class: 'MyJob', first_name: 'John', last_name: 'Doe'}
submitter.send_message(JSON.dump(j))
end
end
- sleep 4
+ sleep 8 # Give it some time to process all the jobs
Process.kill("USR1", pid)
+ sleep 2
generated_files = Dir.glob('*-result')
expect(generated_files).not_to be_empty
generated_files.each{|path| File.unlink(path) }
@@ -30,9 +32,10 @@
it 'on a TERM signal' do
submitter = Sqewer::Connection.default
stderr = Tempfile.new('worker-stderr')
+ stderr.sync = true
pid = fork { $stderr.reopen(stderr); exec("ruby #{__dir__}/cli_app.rb") }
Thread.new do
20.times do