Skip to content
This repository
Browse code

Add support for using an ARCONFIG environment variable to specify the…

… location of the config.yml file for running the tests
  • Loading branch information...
commit 86bbba1ffbd7bf695021d0e6c0f269f808304143 1 parent 15e2891
Jon Leighton authored June 12, 2011
5  activerecord/RUNNING_UNIT_TESTS
@@ -32,3 +32,8 @@ By default the tests run with the Identity Map turned off. But all tests should
32 32
 not the identity map is on or off. You can turn it on using the IM env variable:
33 33
 
34 34
   $ IM=true ruby -Itest test/case/base_test.rb
  35
+
  36
+== Config file
  37
+
  38
+By default, the config file is expected to be at the path test/config.yml. You can specify a
  39
+custom location with the ARCONFIG environment variable.
11  activerecord/test/support/config.rb
@@ -10,13 +10,16 @@ def config
10 10
 
11 11
     private
12 12
 
  13
+    def config_file
  14
+      Pathname.new(ENV['ARCONFIG'] || TEST_ROOT + '/config.yml')
  15
+    end
  16
+
13 17
     def read_config
14  
-      unless File.exist?(TEST_ROOT + '/config.yml')
15  
-        FileUtils.cp TEST_ROOT + '/config.example.yml', TEST_ROOT + '/config.yml'
  18
+      unless config_file.exist?
  19
+        FileUtils.cp TEST_ROOT + '/config.example.yml', config_file
16 20
       end
17 21
 
18  
-      raw = File.read(TEST_ROOT + '/config.yml')
19  
-      erb = Erubis::Eruby.new(raw)
  22
+      erb = Erubis::Eruby.new(config_file.read)
20 23
       expand_config(YAML.parse(erb.result(binding)).transform)
21 24
     end
22 25
 

0 notes on commit 86bbba1

Please sign in to comment.
Something went wrong with that request. Please try again.