Module: Castanet::Testing::CommonTasks

Includes:
ConnectionTesting, Rake::DSL
Included in:
CallbackServerTasks, JasigServerTasks
Defined in:
lib/castanet/testing/common_tasks.rb

Constant Summary

Constants included from ConnectionTesting

Castanet::Testing::ConnectionTesting::LOGGER

Instance Method Summary collapse

Methods included from ConnectionTesting

#responding?

Instance Method Details

#clean_all(scratch_dir, prefix) ⇒ Object



23
24
25
26
27
# File 'lib/castanet/testing/common_tasks.rb', line 23

def clean_all(scratch_dir, prefix)
  files = FileList["#{scratch_dir}/#{prefix}.*"]

  rm_rf files unless files.empty?
end

#wait_all(scratch_dir, timeout) ⇒ Object



12
13
14
15
16
17
18
19
20
21
# File 'lib/castanet/testing/common_tasks.rb', line 12

def wait_all(scratch_dir, timeout)
  Timeout.timeout(timeout) do
    loop do
      urls = Dir["#{scratch_dir}/**/.urls"].map { |x| JSON.parse(File.read(x))['status'] }
      urls.reject! { |u| responding?(u) }
      break true if urls.empty?
      sleep 1
    end
  end
end