Skip to content
Browse files

ActiverecordTestConnector shouldn't be a class

  • Loading branch information...
1 parent dfc3044 commit 36159385c8a5837fc63fe901ebe0a88205b5ce8d @mislav committed Aug 9, 2010
Showing with 10 additions and 8 deletions.
  1. +10 −8 spec/finders/activerecord_test_connector.rb
View
18 spec/finders/activerecord_test_connector.rb
@@ -5,17 +5,19 @@
$query_count = $query_sql = nil
-class ActiverecordTestConnector
- cattr_accessor :able_to_connect
- cattr_accessor :connected
+module ActiverecordTestConnector
+ extend self
+
+ attr_accessor :able_to_connect
+ attr_accessor :connected
FIXTURES_PATH = File.expand_path('../../fixtures', __FILE__)
# Set our defaults
self.connected = false
self.able_to_connect = true
- def self.setup
+ def setup
unless self.connected || !self.able_to_connect
setup_connection
load_schema
@@ -29,12 +31,12 @@ def self.setup
private
- def self.add_load_path(path)
+ def add_load_path(path)
dep = defined?(ActiveSupport::Dependencies) ? ActiveSupport::Dependencies : ::Dependencies
dep.autoload_paths.unshift path
end
- def self.setup_connection
+ def setup_connection
db = ENV['DB'].blank?? 'sqlite3' : ENV['DB']
configurations = YAML.load_file(File.expand_path('../../database.yml', __FILE__))
@@ -49,14 +51,14 @@ def self.setup_connection
prepare ActiveRecord::Base.connection
end
- def self.load_schema
+ def load_schema
ActiveRecord::Base.silence do
ActiveRecord::Migration.verbose = false
load File.join(FIXTURES_PATH, 'schema.rb')
end
end
- def self.prepare(conn)
+ def prepare(conn)
class << conn
IGNORED_SQL = /^(?:PRAGMA|SELECT (?:currval|CAST|@@IDENTITY|@@ROWCOUNT)|SHOW FIELDS)\b/

0 comments on commit 3615938

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