Skip to content

Commit 86bbba1

Browse files
committed
Add support for using an ARCONFIG environment variable to specify the location of the config.yml file for running the tests
1 parent 15e2891 commit 86bbba1

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

activerecord/RUNNING_UNIT_TESTS

+5
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,8 @@ By default the tests run with the Identity Map turned off. But all tests should
3232
not the identity map is on or off. You can turn it on using the IM env variable:
3333

3434
$ 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.

activerecord/test/support/config.rb

+7-4
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,16 @@ def config
1010

1111
private
1212

13+
def config_file
14+
Pathname.new(ENV['ARCONFIG'] || TEST_ROOT + '/config.yml')
15+
end
16+
1317
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
1620
end
1721

18-
raw = File.read(TEST_ROOT + '/config.yml')
19-
erb = Erubis::Eruby.new(raw)
22+
erb = Erubis::Eruby.new(config_file.read)
2023
expand_config(YAML.parse(erb.result(binding)).transform)
2124
end
2225

0 commit comments

Comments
 (0)