Sha256: 58bd9cb5673ba9252f7d57b362ae1398df74e5da820d8ade8343e679ef35ea81

Contents?: true

Size: 1.6 KB

Versions: 3

Compression:

Stored size: 1.6 KB

Contents

require 'rubygems'
require 'bundler/setup'
require 'test/unit'

class Rails
  def self.root
    Pathname.new(File.join(File.dirname(__FILE__), '..'))
  end

  def self.env
    'test'
  end
end

def test_path(glob)
  File.join(Rails.root, 'test', glob)
end

require 'active_support/concern'
require 'active_record'
require 'active_record/fixtures'

def create_fixtures(*table_names, &block)
  Fixtures.create_fixtures(ActiveSupport::TestCase.fixture_path, table_names, {}, &block)
end

require 'sqlite3'
require 'fixture_builder'

class MagicalCreature < ActiveRecord::Base
  validates_presence_of :name, :species
  serialize :powers, Array

  if ActiveRecord::VERSION::MAJOR >= 4
    default_scope -> { where(:deleted => false) }

    attribute :virtual, ActiveRecord::Type::Integer.new
  else
    default_scope :conditions => { :deleted => false }
  end
end

def create_and_blow_away_old_db
  ActiveRecord::Base.configurations['test'] = {
      'adapter' => 'sqlite3',
      'database' => 'test.db'
  }
  ActiveRecord::Base.establish_connection(:test)

  ActiveRecord::Base.connection.create_table(:magical_creatures, :force => true) do |t|
    t.column :name, :string
    t.column :species, :string
    t.column :powers, :string
    t.column :deleted, :boolean, :default => false, :null => false
  end
end

def force_fixture_generation
  begin
    FileUtils.rm(File.expand_path("../../tmp/fixture_builder.yml", __FILE__))
  rescue
  end
end

def force_fixture_generation_due_to_differing_file_hashes
  begin
    path = File.expand_path("../../tmp/fixture_builder.yml", __FILE__)
    File.write(path, "blah blah blah")
  rescue
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
fixture_builder-0.5.3.rc2 test/test_helper.rb
fixture_builder-0.5.3.rc1 test/test_helper.rb
fixture_builder-0.5.2 test/test_helper.rb