unicorn 1.0.2
[unicorn.git] / t / t0303-rails3-alt-working_directory_config.ru.sh
blob444f05acd03e7ec6cc96e4254ad3298851ade5b1
1 #!/bin/sh
2 if test -n "$RBX_SKIP"
3 then
4 echo "$0 is broken under Rubinius for now"
5 exit 0
6 fi
7 . ./test-rails3.sh
9 t_plan 5 "Rails 3 (beta) inside alt working_directory (w/ config.ru)"
11 t_begin "setup and start" && {
12 unicorn_setup
13 rtmpfiles unicorn_config_tmp usocket
14 if test -e $usocket
15 then
16 die "unexpected $usocket"
18 rails3_app=$(cd rails3-app && pwd)
19 rm -rf $t_pfx.app
20 mkdir $t_pfx.app
21 cd $t_pfx.app
22 ( cd $rails3_app && tar cf - . ) | tar xf -
23 $RAKE db:sessions:create
24 $RAKE db:migrate
25 unicorn_setup
26 rm $pid
28 echo "#\\--daemonize --host $host --port $port -l $usocket" \
29 >> $t_pfx.app/config.ru
31 # we have --host/--port in config.ru instead
32 grep -v ^listen $unicorn_config |
33 grep -v ^pid > $unicorn_config_tmp
34 echo "working_directory '$t_pfx.app'" >> $unicorn_config_tmp
35 cd /
36 unicorn_rails -c $unicorn_config_tmp
39 t_begin "pids in the right place" && {
40 if test -e $pid
41 then
42 die "pid=$pid not expected"
45 unicorn_rails_pid="$t_pfx.app/tmp/pids/unicorn.pid"
46 unicorn_pid=$(cat $unicorn_rails_pid)
49 t_begin "static file serving works" && {
50 test x"$(curl -sSf http://$listen/x.txt)" = xHELLO
53 t_begin "socket created" && {
54 test -S $usocket
57 t_begin "killing succeeds" && {
58 kill $unicorn_pid
61 t_done