loud boot.rb
[has_many_polymorphs.git] / test / integration / server_test.rb
blobaa8322b35912df2e02adc4ec469bae0dd85a2520
2 require "#{File.dirname(__FILE__)}/../test_helper"
3 require 'open-uri'
5 # Start the server
7 class ServerTest < Test::Unit::TestCase
9   PORT = 43040
10   URL = "http://localhost:#{PORT}/"
12   def setup
13     @pid = Process.fork do
14        Dir.chdir RAILS_ROOT do
15          # print "S"
16          exec("script/server -p #{PORT} > /dev/null")
17        end
18      end
19      sleep(5)
20   end
21   
22   def teardown
23     # Process.kill(9, @pid) doesn't work because Mongrel has double-forked itself away
24     `ps awx | grep #{PORT} | grep -v grep | awk '{print $1}'`.split("\n").each do |pid|
25       system("kill -9 #{pid}")
26       # print "K"
27     end
28     sleep(2)
29     @pid = nil
30   end
31   
32   def test_association_reloading
33     4.times do
34       assert_match(/Bones: index/, open(URL + 'bones').read)
35     end
36   end
37   
38 end