Sha256: f138c9cf1d27b52e48a40361894d9e9b444aa9ba2c33b7b33f9948647661a75a

Contents?: true

Size: 903 Bytes

Versions: 18

Compression:

Stored size: 903 Bytes

Contents

require 'support/active_record/database_setup'
require 'support/active_record/schema_setup'

module MySQLHelper
  puts "Active Record #{ActiveRecord::VERSION::STRING}, mysql"

  # require 'logger'
  # ActiveRecord::Base.logger = Logger.new(STDERR)

  def default_config
    db_config['mysql']
  end

  def create_db
    establish_connection(default_config.merge(:database => nil))

    ActiveRecord::Base.connection.drop_database default_config['database'] rescue nil
    ActiveRecord::Base.connection.create_database default_config['database']
  end

  def establish_connection(config = default_config)
    ActiveRecord::Base.establish_connection config
  end

  def active_record_mysql_setup
    create_db
    establish_connection
    active_record_load_schema
  end

  def active_record_mysql_connection
    ActiveRecord::Base.connection
  end
end

RSpec.configure do |c|
  c.include MySQLHelper
end

Version data entries

18 entries across 18 versions & 3 rubygems

Version Path
database_cleaner-1.6.2 spec/support/active_record/mysql_setup.rb
database_cleaner-1.6.1 spec/support/active_record/mysql_setup.rb
database_cleaner-1.6.0 spec/support/active_record/mysql_setup.rb
autocompl-0.2.2 test/dummy/vendor/bundle/ruby/2.3.0/gems/database_cleaner-1.5.3/spec/support/active_record/mysql_setup.rb
autocompl-0.2.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/database_cleaner-1.5.3/spec/support/active_record/mysql_setup.rb
autocompl-0.2.0 test/dummy/vendor/bundle/ruby/2.3.0/gems/database_cleaner-1.5.3/spec/support/active_record/mysql_setup.rb
autocompl-0.1.2 test/dummy/vendor/bundle/ruby/2.3.0/gems/database_cleaner-1.5.3/spec/support/active_record/mysql_setup.rb
autocompl-0.1.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/database_cleaner-1.5.3/spec/support/active_record/mysql_setup.rb
autocompl-0.1.0 test/dummy/vendor/bundle/ruby/2.3.0/gems/database_cleaner-1.5.3/spec/support/active_record/mysql_setup.rb
autocompl-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/database_cleaner-1.5.3/spec/support/active_record/mysql_setup.rb
database_cleaner-1.5.3 spec/support/active_record/mysql_setup.rb
database_cleaner-1.5.2 spec/support/active_record/mysql_setup.rb
database_cleaner-1.5.1 spec/support/active_record/mysql_setup.rb
database_cleaner-1.5.0 spec/support/active_record/mysql_setup.rb
solidus_backend-1.0.0.pre3 vendor/bundle/gems/database_cleaner-1.4.1/spec/support/active_record/mysql_setup.rb
solidus_backend-1.0.0.pre2 vendor/bundle/gems/database_cleaner-1.4.1/spec/support/active_record/mysql_setup.rb
solidus_backend-1.0.0.pre vendor/bundle/gems/database_cleaner-1.4.1/spec/support/active_record/mysql_setup.rb
database_cleaner-1.4.1 spec/support/active_record/mysql_setup.rb