Skip to content
Browse files

Tests can now be run without a host Rails application (standalone)

  • Loading branch information...
1 parent 8367994 commit 34ab8c3ac9b7d87069670cf828f23dfe02f33a0f @adambair adambair committed Jul 16, 2009
Showing with 12 additions and 11 deletions.
  1. +2 −5 test/database.yml
  2. +10 −6 test/test_harness.rb
View
7 test/database.yml
@@ -1,6 +1,3 @@
-sqlite:
- :adapter: sqlite
- :dbfile: vendor/plugins/fu-fu/test/profanity_filter.sqlite.db
-sqlite3:
+test:
:adapter: sqlite3
- :dbfile: vendor/plugins/fu-fu/test/profanity_filter.sqlite3.db
+ :dbfile: ":memory:"
View
16 test/test_harness.rb
@@ -2,17 +2,21 @@
require 'yaml'
begin
- require File.dirname(__FILE__) + '/../../../../config/boot'
- require 'active_record'
+ require File.dirname(__FILE__) + '/../../../../config/environment'
rescue LoadError
require 'rubygems'
- require_gem 'activerecord'
+ gem 'activerecord'
+ gem 'actionpack'
+ require 'active_record'
+ require 'action_controller'
end
require File.dirname(__FILE__) + '/../lib/profanity_filter'
-config = YAML::load(IO.read(File.dirname(__FILE__) + '/database.yml'))
ActiveRecord::Base.logger = Logger.new(File.dirname(__FILE__) + '/debug.log')
-ActiveRecord::Base.establish_connection(config[ENV['DB'] || 'sqlite3'])
+ActiveRecord::Base.configurations = YAML::load(IO.read(File.dirname(__FILE__) + '/database.yml'))
+ActiveRecord::Base.establish_connection('test')
load(File.dirname(__FILE__) + "/schema.rb")
-ActiveRecord::Base.send(:include, ProfanityFilter)
+
+ActiveRecord::Base.send(:include, ProfanityFilter)
+

0 comments on commit 34ab8c3

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