Sha256: 0b1dba55f40f6bd138f6fa019db7842c6e94f94af2ff443e84b5c5c2cb88266f

Contents?: true

Size: 1.63 KB

Versions: 11

Compression:

Stored size: 1.63 KB

Contents

require 'simplecov'
require 'simplecov-gem-profile'
SimpleCov.use_merging true
SimpleCov.merge_timeout 3600
SimpleCov.start "gem"

$LOAD_PATH.unshift(File.dirname(__FILE__))
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))

require 'rspec'
require 'active_record'
require 'schema_plus'
require 'schema_dev/rspec'
require 'its-it'

SchemaDev::Rspec.setup_db

Dir[File.dirname(__FILE__) + "/support/**/*.rb"].each {|f| require f}

RSpec.configure do |config|
  config.include(SchemaPlusMatchers)
  config.include(SchemaPlusHelpers)
  config.warnings = true
end

def with_fk_config(opts, &block)
  save = Hash[opts.keys.collect{|key| [key, SchemaPlus.config.foreign_keys.send(key)]}]
  begin
    SchemaPlus.config.foreign_keys.update_attributes(opts)
    yield
  ensure
    SchemaPlus.config.foreign_keys.update_attributes(save)
  end
end

def with_fk_auto_create(value = true, &block)
  with_fk_config(:auto_create => value, &block)
end

def define_schema(config={}, &block)
  with_fk_config(config) do
    ActiveRecord::Migration.suppress_messages do
      ActiveRecord::Schema.define do
        connection.tables.each do |table|
          drop_table table, :cascade => true
        end
        instance_eval &block
      end
    end
  end
end

def remove_all_models
    ObjectSpace.each_object(Class) do |c|
      next unless c.ancestors.include? ActiveRecord::Base
      next if c == ActiveRecord::Base
      next if c.name.blank?
      ActiveSupport::Dependencies.remove_constant c.name
    end
  end

SimpleCov.command_name "[ruby #{RUBY_VERSION} - ActiveRecord #{::ActiveRecord::VERSION::STRING} - #{ActiveRecord::Base.connection.adapter_name}]"

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
schema_plus-1.8.9 spec/spec_helper.rb
schema_plus-1.8.8 spec/spec_helper.rb
schema_plus-1.8.7 spec/spec_helper.rb
schema_plus-1.8.6 spec/spec_helper.rb
schema_plus-1.8.5 spec/spec_helper.rb
schema_plus-1.8.4 spec/spec_helper.rb
schema_plus-1.8.3 spec/spec_helper.rb
schema_plus-1.8.2 spec/spec_helper.rb
schema_plus-1.8.1 spec/spec_helper.rb
schema_plus-1.8.0 spec/spec_helper.rb
schema_plus-1.7.1 spec/spec_helper.rb