public
Rubygem
Description: A very fast & simple Ruby web server
Homepage: http://code.macournoyer.com/thin/
Clone URL: git://github.com/macournoyer/thin.git
Click here to lend your support to: thin and make a donation at www.pledgie.com !
Set RACK_ENV based on environment option when loading rackup file [Curtis 
Summers] [#83 state:resolved]
macournoyer (author)
Tue Oct 21 20:26:44 -0700 2008
commit  1e90d63f9139f6bc5dc7624ef07076bedcbb0bb3
tree    1d29c169bc56e3ecc1513904ef35311aea58fbd0
parent  4d224bd3fe0824387da3cbb5390a02a8bd775c28
...
1
 
2
3
4
...
1
2
3
4
5
0
@@ -1,4 +1,5 @@
0
 == 1.0.1 ? release
0
+ * Set RACK_ENV based on environment option when loading rackup file [Curtis Summers] [#83 state:resolved]
0
  * Fixes a warning RE relative_url_root when using a prefix with Rails 2.1.1 [seriph] [#85 state:resolved]
0
  * --only can work as a sequence number (if < 80) or a port number (if >= 80) [jmay] [#81 state:resolved]
0
 
...
166
167
168
 
169
170
171
...
166
167
168
169
170
171
172
0
@@ -166,6 +166,7 @@ module Thin
0
         end
0
         
0
         def load_rackup_config
0
+          ENV['RACK_ENV'] = @options[:environment]
0
           case @options[:rackup]
0
           when /\.rb$/
0
             Kernel.load(@options[:rackup])
...
63
64
65
66
 
67
68
69
70
71
72
73
 
74
75
76
...
78
79
80
81
 
82
83
84
...
89
90
91
 
 
 
 
 
 
 
 
92
93
94
...
63
64
65
 
66
67
68
69
70
71
72
 
73
74
75
76
...
78
79
80
 
81
82
83
84
...
89
90
91
92
93
94
95
96
97
98
99
100
101
102
0
@@ -63,14 +63,14 @@ describe Controller, 'start' do
0
   end
0
   
0
   it "should load app from Rack config" do
0
-    @controller.options[:rackup] = File.dirname(__FILE__) + '/../../example/config.ru'    
0
+    @controller.options[:rackup] = File.dirname(__FILE__) + '/../../example/config.ru'
0
     @controller.start
0
     
0
     @server.app.class.should == Proc
0
   end
0
 
0
   it "should load app from ruby file" do
0
-    @controller.options[:rackup] = filename = File.dirname(__FILE__) + '/../../example/myapp.rb'    
0
+    @controller.options[:rackup] = File.dirname(__FILE__) + '/../../example/myapp.rb'
0
     @controller.start
0
     
0
     @server.app.should == Myapp
0
@@ -78,7 +78,7 @@ describe Controller, 'start' do
0
 
0
   it "should throwup if rackup is not a .ru or .rb file" do
0
     proc do
0
-      @controller.options[:rackup] = filename = File.dirname(__FILE__) + '/../../example/myapp.foo'    
0
+      @controller.options[:rackup] = File.dirname(__FILE__) + '/../../example/myapp.foo'
0
       @controller.start
0
     end.should raise_error(RuntimeError, /please/)
0
   end
0
@@ -89,6 +89,14 @@ describe Controller, 'start' do
0
     
0
     @server.threaded.should be_true
0
   end
0
+  
0
+  it "should set RACK_ENV" do
0
+    @controller.options[:rackup] = File.dirname(__FILE__) + '/../../example/config.ru'
0
+    @controller.options[:environment] = "lolcat"
0
+    @controller.start
0
+    
0
+    ENV['RACK_ENV'].should == "lolcat"
0
+  end
0
     
0
 end
0
 

Comments