Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Updating test_helper so it actually runs tests

  • Loading branch information...
commit a27cee476d1775c13bc910d9cff902d1c4bd38a1 1 parent bb9c40e
@qrush qrush authored
Showing with 38 additions and 39 deletions.
  1. +38 −39 test/test_helper.rb
View
77 test/test_helper.rb
@@ -1,39 +1,38 @@
-require 'rubygems'
-require 'test/unit'
-require 'active_record'
-require 'active_record/fixtures'
-
-config = YAML::load(IO.read(File.dirname(__FILE__) + '/database.yml'))
-RAILS_DEFAULT_LOGGER = ActiveRecord::Base.logger = Logger.new(File.dirname(__FILE__) + "/debug.log")
-ActiveRecord::Base.establish_connection(config[ENV['DB'] || 'sqlite3'])
-
-load(File.dirname(__FILE__) + "/schema.rb") if File.exist?(File.dirname(__FILE__) + "/schema.rb")
-
-Test::Unit::TestCase.fixture_path = File.dirname(__FILE__) + "/fixtures/"
-$LOAD_PATH.unshift(Test::Unit::TestCase.fixture_path)
-
-class Test::Unit::TestCase #:nodoc:
- def create_fixtures(*table_names)
- if block_given?
- Fixtures.create_fixtures(Test::Unit::TestCase.fixture_path, table_names) { yield }
- else
- Fixtures.create_fixtures(Test::Unit::TestCase.fixture_path, table_names)
- end
- end
-
- def self.load_all_fixtures
- all_fixtures = Dir.glob("#{File.dirname(__FILE__)}/fixtures/*.yml").collect do |f|
- puts "Loading fixture '#{f}'"
- File.basename(f).gsub(/\.yml$/, "").to_sym
- end
- Fixtures.create_fixtures(Test::Unit::TestCase.fixture_path, all_fixtures)
- end
-
- # Turn off transactional fixtures if you're working with MyISAM tables in MySQL
- self.use_transactional_fixtures = true
-
- # Instantiated fixtures are slow, but give you @david where you otherwise would need people(:david)
- self.use_instantiated_fixtures = false
-
- # Add more helper methods to be used by all tests here...
-end
+require 'rubygems'
+require 'test/unit'
+require 'active_record'
+require 'active_record/fixtures'
+
+config = YAML::load(IO.read(File.dirname(__FILE__) + '/database.yml'))
+RAILS_DEFAULT_LOGGER = ActiveRecord::Base.logger = Logger.new(File.dirname(__FILE__) + "/debug.log")
+ActiveRecord::Base.establish_connection(config[ENV['DB'] || 'sqlite3'])
+
+load(File.dirname(__FILE__) + "/schema.rb") if File.exist?(File.dirname(__FILE__) + "/schema.rb")
+
+class Test::Unit::TestCase #:nodoc:
+ class << self
+ # http://www.gamecreatures.com/blog/2007/08/05/rails-unit-test-fixture_path-nameerror/
+ def fixture_path
+ File.dirname(__FILE__) + '/fixtures/'
+ end
+
+ use_transactional_fixtures = true
+ use_instantiated_fixtures = false
+
+ def load_all_fixtures
+ all_fixtures = Dir.glob("#{File.dirname(__FILE__)}/fixtures/*.yml").collect do |f|
+ puts "Loading fixture '#{f}'"
+ File.basename(f).gsub(/\.yml$/, "").to_sym
+ end
+ Fixtures.create_fixtures(Test::Unit::TestCase.fixture_path, all_fixtures)
+ end
+ end
+
+ def create_fixtures(*table_names)
+ if block_given?
+ Fixtures.create_fixtures(Test::Unit::TestCase.fixture_path, table_names) { yield }
+ else
+ Fixtures.create_fixtures(Test::Unit::TestCase.fixture_path, table_names)
+ end
+ end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.