GitHub Sale: sign up for any paid plan this week and pay nothing until January 1, 2009!  [ hide ]

public
Rubygem
Description: Merb Core: All you need. None you don't.
Homepage: http://www.merbivore.com
Clone URL: git://github.com/wycats/merb-core.git
Added Merb.testing? method

This will check for either $TESTING (as used by merb internals/plugins) or 
Merb::Config[:testing], which can be set in the config options. Having an 
option like this provides a nice interface for the more public facing 
parts of Merb; the auto-generated spec_helper.rb file for example can just 
use the test environment setting.
fabien (author)
Tue Mar 11 01:47:18 -0700 2008
commit  209ab5ce04f2b2b2579a12228139653af5049616
tree    5808a4b8ce659b0e877393cdd972b09af6fc3d11
parent  ff17f772b2bd30f8d57c9aa6920d4b0e83dd1d48
...
124
125
126
127
 
128
129
130
...
193
194
195
196
 
 
 
 
 
 
 
 
 
 
197
198
199
200
201
202
203
 
204
205
206
...
210
211
212
 
 
 
 
 
 
213
214
215
...
287
288
289
290
291
 
292
...
124
125
126
 
127
128
129
130
...
193
194
195
 
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
 
 
211
212
213
214
...
218
219
220
221
222
223
224
225
226
227
228
229
...
301
302
303
 
304
305
306
0
@@ -124,7 +124,7 @@ module Merb
0
     def log_file
0
       if Merb::Config[:log_file]
0
         Merb::Config[:log_file]
0
- elsif $TESTING
0
+ elsif Merb.testing?
0
         log_path / "merb_test.log"
0
       elsif !(Merb::Config[:daemonize] || Merb::Config[:cluster])
0
         STDOUT
0
@@ -193,14 +193,22 @@ module Merb
0
     def frozen!
0
       @frozen = true
0
     end
0
-
0
+
0
+ # Load configuration and assign logger.
0
+ #
0
+ # ==== Parameters
0
+ # options<Hash>:: Options to pass on to the Merb config.
0
+ def load_config(options = {})
0
+ Merb::Config.setup({ :log_file => STDOUT, :log_level => :warn, :log_auto_flush => true }.merge(options))
0
+ Merb::BootLoader::Logger.run
0
+ end
0
+
0
     # Load all basic dependencies (selected BootLoaders only).
0
     #
0
     # ==== Parameters
0
     # options<Hash>:: Options to pass on to the Merb config.
0
     def load_dependencies(options = {})
0
- Merb::Config.setup({ :log_file => $stdout, :log_level => :warn, :log_auto_flush => true }.merge(options))
0
- Merb::BootLoader::Logger.run
0
+ load_config(options)
0
       Merb::BootLoader::BuildFramework.run
0
       Merb::BootLoader::Dependencies.run
0
       Merb::BootLoader::BeforeAppRuns.run
0
@@ -210,6 +218,12 @@ module Merb
0
     def reload
0
       Merb::BootLoader::ReloadClasses.reload
0
     end
0
+
0
+ # ==== Returns
0
+ # Boolean:: True if Merb is running via script/frozen-merb or other freezer.
0
+ def testing?
0
+ $TESTING || Merb::Config[:testing]
0
+ end
0
 
0
     # If block was given configures using the block.
0
     #
0
@@ -287,4 +301,4 @@ require 'merb-core/controller/mime'
0
 require 'merb-core/vendor/facets'
0
 
0
 # Set the environment if it hasn't already been set.
0
-Merb.environment ||= ENV['MERB_ENV'] || Merb::Config[:environment] || ($TESTING ? 'test' : 'development')
0
\ No newline at end of file
0
+Merb.environment ||= ENV['MERB_ENV'] || Merb::Config[:environment] || (Merb.testing? ? 'test' : 'development')
0
\ No newline at end of file
...
125
126
127
 
 
 
 
 
 
 
 
 
 
 
128
129
...
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
0
@@ -125,4 +125,15 @@ describe Merb::Config do
0
     Merb.disabled?(:foo, :buz).should == true
0
   end
0
   
0
+ it "should take Merb.testing? into account" do
0
+ $TESTING.should == true
0
+ Merb::Config[:testing].should be_nil
0
+ Merb.should be_testing
0
+ $TESTING = false
0
+ Merb.should_not be_testing
0
+ Merb::Config[:testing] = true
0
+ Merb.should be_testing
0
+ $TESTING = true; Merb::Config[:testing] = false # reset
0
+ end
0
+
0
 end
0
\ No newline at end of file
...
1
2
3
4
5
...
1
 
2
3
4
0
@@ -1,5 +1,4 @@
0
 $TESTING=true
0
-
0
 require "rubygems"
0
 require "spec"
0
 require File.join(File.dirname(__FILE__), "..", "lib", "merb-core")

Comments

    No one has commented yet.