about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2009-11-05 01:50:17 -0800
committerEric Wong <normalperson@yhbt.net>2009-11-05 01:50:17 -0800
commit8ce1ba6cc7409e5c6b04286bdf09bc175a0274fb (patch)
tree881f02000435f9727c9d9cadf3a417a2d4ba3515
parentb5c1db0c2cd95bcfba1e67fa8a0a058f80025528 (diff)
downloadrainbows-8ce1ba6cc7409e5c6b04286bdf09bc175a0274fb.tar.gz
Add tests to ensure we set it correctly and it gets
passed down to the app.
-rw-r--r--bin/rainbows2
-rw-r--r--t/env_rack_env.ru4
-rwxr-xr-xt/t0006-process-rack-env.sh40
3 files changed, 45 insertions, 1 deletions
diff --git a/bin/rainbows b/bin/rainbows
index eec54b0..c5c3d87 100644
--- a/bin/rainbows
+++ b/bin/rainbows
@@ -4,7 +4,7 @@ require 'unicorn/launcher'
 require 'rainbows'
 require 'optparse'
 
-ENV["RACK_ENV"] = "development"
+ENV["RACK_ENV"] ||= "development"
 daemonize = false
 listeners = []
 options = { :listeners => listeners }
diff --git a/t/env_rack_env.ru b/t/env_rack_env.ru
new file mode 100644
index 0000000..7f12b29
--- /dev/null
+++ b/t/env_rack_env.ru
@@ -0,0 +1,4 @@
+use Rack::ContentLength
+run proc { |env|
+  [ 200, { "Content-Type" => "text/plain" }, [ ENV["RACK_ENV"] ] ]
+}
diff --git a/t/t0006-process-rack-env.sh b/t/t0006-process-rack-env.sh
new file mode 100755
index 0000000..7ee7c15
--- /dev/null
+++ b/t/t0006-process-rack-env.sh
@@ -0,0 +1,40 @@
+#!/bin/sh
+. ./test-lib.sh
+
+t_plan 4 'ensure ENV["RACK_ENV"] is set correctly for '$model
+
+finish_checks () {
+        kill $rainbows_pid
+        test ! -s $curl_err
+        check_stderr
+}
+
+t_begin "setup" && {
+        rtmpfiles curl_out curl_err
+}
+
+t_begin "default RACK_ENV is 'development'" && {
+        rainbows_setup
+        rainbows -D -c $unicorn_config env_rack_env.ru
+        rainbows_wait_start
+        test x"$(curl -sSf http://$listen 2>$curl_err)" = x"development"
+        finish_checks
+}
+
+t_begin "RACK_ENV from process ENV is inherited" && {
+        rainbows_setup
+        ( RACK_ENV=production rainbows -D -c $unicorn_config env_rack_env.ru )
+        rainbows_wait_start
+        test x$(curl -sSf http://$listen 2>$curl_err) = x"production"
+        finish_checks
+}
+
+t_begin "RACK_ENV from -E is set" && {
+        rainbows_setup
+        rainbows -D -c $unicorn_config -E none env_rack_env.ru
+        rainbows_wait_start
+        test x$(curl -sSf http://$listen 2>$curl_err) = x"none"
+        finish_checks
+}
+
+t_done