Sha256: 7cbc4963b2dfbd79c5bd0bfaed0b8285576ba416808342ca9523ce544708d2df

Contents?: true

Size: 1.88 KB

Versions: 3

Compression:

Stored size: 1.88 KB

Contents

module CsvDictionaryTestHelper
  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_dictionary'
  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 :aircraft do |t|
        t.string :brighter_planet_aircraft_class_code
        t.timestamps
      end
      create_table :scrums do |t|
        t.string :name
        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

CsvDictionaryTestHelper.start

ActiveSupport::Inflector.inflections do |inflect|
  inflect.uncountable('aircraft')
end

class Aircraft < ActiveRecord::Base; end
class Scrum < ActiveRecord::Base; end

GDOCS_URL = 'http://spreadsheets.google.com/pub?key=p70r3FHguhimD8YmyA34RdA'
CSV_URL = 'http://static.brighterplanet.com/science/data/transport/air/bts_aircraft_types-brighter_planet_aircraft_classes.csv'

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
seamusabshere-csv_dictionary-0.0.1 test/test_helper.rb
seamusabshere-csv_dictionary-0.0.2 test/test_helper.rb
seamusabshere-csv_dictionary-0.0.3 test/test_helper.rb