Sha256: e1fc2427d3f26ce278b22e8291fcd975f1a426766e827d730bd2023232d9baa4
Contents?: true
Size: 1.28 KB
Versions: 3
Compression:
Stored size: 1.28 KB
Contents
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) $LOAD_PATH.unshift(File.dirname(__FILE__)) require 'rspec' require 'httpclient' require 'daemon' # Requires supporting files with custom matchers and macros, etc, # in ./support/ and its subdirectories. Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f} RSpec.configure do |config| end def support_dir Pathname.new('spec/support') end def get(url) HTTPClient.new.get_content(url) end def status(url) HTTPClient.new.get(url).status end def headers(url) HTTPClient.new.get(url).headers end def start_server(cmd, pid_file, log_file, test_url) fork do Daemon.daemonize(pid_file, log_file) log_file = Pathname.new(log_file) log_file.truncate(0) if log_file.exist? exec(cmd) end return unless Process.wait2.last.exitstatus == 0 ppid = Process.pid at_exit do stop_server(pid_file) if Process.pid == ppid end Timeout.timeout(6) do begin get test_url rescue Errno::ECONNREFUSED sleep 0.1 retry end end end def stop_server(pid_file) pid_file = Pathname.new(pid_file) return unless pid_file.exist? pid = pid_file.read.strip.to_i Timeout.timeout(20) do begin loop do Process.kill("TERM", pid) sleep 0.1 end rescue Errno::ESRCH pid_file.unlink end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
httpimagestore-1.2.0 | spec/spec_helper.rb |
httpimagestore-1.1.0 | spec/spec_helper.rb |
httpimagestore-1.0.0 | spec/spec_helper.rb |