Sha256: 17b0f14c5fa342ace3974249c87e4ab7a51b707c38c910575c42fb65190c9427

Contents?: true

Size: 1.67 KB

Versions: 2

Compression:

Stored size: 1.67 KB

Contents

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'

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
seamusabshere-csv_bootstrap-0.1.0 test/test_helper.rb
seamusabshere-csv_bootstrap-0.1.1 test/test_helper.rb