module CsvBootstrapTestHelper VENDOR_RAILS = File.expand_path('../../../../rails', __FILE__) OTHER_RAILS = File.expand_path('../../../rails', __FILE__) PLUGIN_ROOT = File.expand_path('../../', __FILE__) def self.rails_directory if File.exist?(VENDOR_RAILS) VENDOR_RAILS elsif File.exist?(OTHER_RAILS) OTHER_RAILS end end def self.load_dependencies if rails_directory $:.unshift(File.join(rails_directory, 'activesupport', 'lib')) $:.unshift(File.join(rails_directory, 'activerecord', 'lib')) else require 'rubygems' rescue LoadError end require 'active_record' require 'test/unit' require 'mocha' $LOAD_PATH.unshift(File.dirname(__FILE__)) $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) require 'csv_bootstrap' end def self.configure_database ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :dbfile => ":memory:") ActiveRecord::Migration.verbose = false end def self.setup_database ActiveRecord::Schema.define do create_table :scrums do |t| t.string :name t.string :emission_factor t.string :units t.timestamps end end end def self.teardown_database ActiveRecord::Base.connection.tables.each do |table| ActiveRecord::Base.connection.drop_table(table) end end def self.start load_dependencies configure_database end end CsvBootstrapTestHelper.start class Scrum < ActiveRecord::Base; end GDOCS_URL = 'http://spreadsheets.google.com/pub?key=p70r3FHguhimIdBKyVz3iPA' CSV_URL = 'http://static.brighterplanet.com/science/data/transport/air/iata_codes-bts_aircraft_types.csv'