We got nominated! Help us out and vote for GitHub as Best Bootstrapped Startup of 2008. (You can vote once a day.) [ hide ]

public
Fork of fiveruns/data_fabric
Homepage: http://fiveruns.rubyforge.org/data_fabric
Clone URL: git://github.com/FooBarWidget/data_fabric.git
Remove database.yml from the repository so that each developer can specify 
its own database details.
Hongli Lai (Phusion) (author)
Fri Aug 29 07:50:43 -0700 2008
commit  7b7efacc3f6aa9cae20c6da21830cc4bd22d0fae
tree    01a6e56d50de5276d8fae21e13a58124a358a5b8
parent  b77814b08df17eb3eaa8fd8a434e490a630b811b
...
9
10
11
12
13
 
14
15
16
...
36
37
38
39
40
 
...
9
10
11
 
 
12
13
14
15
...
35
36
37
 
38
39
0
@@ -9,8 +9,7 @@ end
0
 class DatabaseTest < Test::Unit::TestCase
0
   
0
   def setup
0
- filename = File.join(File.dirname(__FILE__), "database.yml")
0
- ActiveRecord::Base.configurations = YAML::load(ERB.new(IO.read(filename)).result)
0
+ ActiveRecord::Base.configurations = load_database_yml
0
   end
0
 
0
   def test_live_burrito
0
@@ -36,4 +35,4 @@ class DatabaseTest < Test::Unit::TestCase
0
       end
0
     end
0
   end
0
-end
0
\ No newline at end of file
0
+end
...
1
2
 
 
 
 
 
 
3
4
5
 
 
6
7
8
9
10
11
12
13
 
 
 
 
 
 
 
14
15
16
17
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
 
 
1
2
3
4
5
6
7
 
 
8
9
10
 
 
 
 
 
 
 
11
12
13
14
15
16
17
18
 
 
 
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
0
@@ -1,17 +1,34 @@
0
-ENV['RAILS_ENV']='test'
0
-RAILS_ENV='test'
0
+if !defined?(ROOT_PATH) # Don't evaluate this file twice.
0
+ ENV['RAILS_ENV'] = 'test'
0
+ RAILS_ENV = 'test'
0
+ ROOT_PATH = File.expand_path(File.join(File.dirname(__FILE__), ".."))
0
+ DATABASE_YML_PATH = File.join(ROOT_PATH, "test", "database.yml")
0
+ Dir.chdir(ROOT_PATH)
0
 
0
-require 'rubygems'
0
-require 'test/unit'
0
+ require 'rubygems'
0
+ require 'test/unit'
0
 
0
-# Bootstrap AR
0
-gem 'activerecord', '=2.0.2'
0
-require 'active_record'
0
-require 'active_record/version'
0
-ActiveRecord::Base.logger = Logger.new(STDOUT)
0
-ActiveRecord::Base.logger.level = Logger::WARN
0
-ActiveRecord::Base.allow_concurrency = false
0
+ # Bootstrap AR
0
+ gem 'activerecord', '=2.0.2'
0
+ require 'active_record'
0
+ require 'active_record/version'
0
+ ActiveRecord::Base.logger = Logger.new(STDOUT)
0
+ ActiveRecord::Base.logger.level = Logger::WARN
0
+ ActiveRecord::Base.allow_concurrency = false
0
 
0
-# Bootstrap DF
0
-Dependencies.load_paths << File.join(File.dirname(__FILE__), '../lib')
0
-require 'init'
0
+ # Bootstrap DF
0
+ Dependencies.load_paths << File.join(File.dirname(__FILE__), '../lib')
0
+ require 'init'
0
+
0
+ def load_database_yml
0
+ filename = DATABASE_YML_PATH
0
+ ActiveRecord::Base.configurations = YAML::load(ERB.new(IO.read(filename)).result)
0
+ end
0
+
0
+ if !File.exist?(DATABASE_YML_PATH)
0
+ STDERR.puts "\n*** ERROR ***:\n" <<
0
+ "You must have a 'test/database.yml' file in order to run the unit tests. " <<
0
+ "An example is provided in 'test/database.yml.example'.\n\n"
0
+ exit 1
0
+ end
0
+end
...
18
19
20
21
22
 
23
24
25
...
30
31
32
33
 
34
35
36
...
88
89
90
91
92
 
...
18
19
20
 
 
21
22
23
24
...
29
30
31
 
32
33
34
35
...
87
88
89
 
90
91
0
@@ -18,8 +18,7 @@ class ThreadTest < Test::Unit::TestCase
0
   end
0
   
0
   def xtest_class_and_instance_connections
0
- filename = File.join(File.dirname(__FILE__), "database.yml")
0
- ActiveRecord::Base.configurations = YAML::load(ERB.new(IO.read(filename)).result)
0
+ ActiveRecord::Base.configurations = load_database_yml
0
 
0
     cconn = ThreadedEnchilada.connection
0
     iconn = ThreadedEnchilada.new.connection
0
@@ -30,7 +29,7 @@ class ThreadTest < Test::Unit::TestCase
0
     clear_databases
0
 
0
     filename = File.join(File.dirname(__FILE__), "database.yml")
0
- ActiveRecord::Base.configurations = YAML::load(ERB.new(IO.read(filename)).result)
0
+ ActiveRecord::Base.configurations = load_database_yml
0
 
0
     counts = {:austin => 0, :dallas => 0}
0
     threads = []
0
@@ -88,4 +87,4 @@ class ThreadTest < Test::Unit::TestCase
0
   def using_connection(&block)
0
     ActiveRecord::Base.connection.instance_eval(&block)
0
   end
0
-end
0
\ No newline at end of file
0
+end

Comments

    No one has commented yet.