Sha256: c2631e481642970a5761d866e8ca813f04994f7218d4a3bea9cc8479ec2a5951

Contents?: true

Size: 848 Bytes

Versions: 14

Compression:

Stored size: 848 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 config
    db_config['mysql']
  end

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

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

  def establish_connection config = config
    ActiveRecord::Base.establish_connection config
  end

  def active_record_mysql_setup
    create_db
    establish_connection
    load_schema
  end

  def active_record_mysql_connection
    ActiveRecord::Base.connection
  end
end

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

Version data entries

14 entries across 9 versions & 3 rubygems

Version Path
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/apl-library-0.0.90/vendor/bundle/ruby/2.1.0/gems/database_cleaner-1.2.0/spec/support/active_record/mysql_setup.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/database_cleaner-1.2.0/spec/support/active_record/mysql_setup.rb
apl-library-0.0.90 vendor/bundle/ruby/1.8/gems/database_cleaner-1.2.0/spec/support/active_record/mysql_setup.rb
apl-library-0.0.90 vendor/bundle/ruby/1.9.1/gems/database_cleaner-1.2.0/spec/support/active_record/mysql_setup.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/apl-library-0.0.90/vendor/bundle/ruby/1.8/gems/database_cleaner-1.2.0/spec/support/active_record/mysql_setup.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/apl-library-0.0.90/vendor/bundle/ruby/1.9.1/gems/database_cleaner-1.2.0/spec/support/active_record/mysql_setup.rb
database_cleaner-1.3.0 spec/support/active_record/mysql_setup.rb
database_cleaner-1.2.0 spec/support/active_record/mysql_setup.rb
database_cleaner-1.1.1 spec/support/active_record/mysql_setup.rb
database_cleaner-1.1.0 spec/support/active_record/mysql_setup.rb
database_cleaner-1.0.1 spec/support/active_record/mysql_setup.rb
database_cleaner-1.0.0.RC1 spec/support/active_record/mysql_setup.rb
sunrise-cms-0.5.0.rc1 vendor/bundle/ruby/1.9.1/gems/database_cleaner-0.9.1/spec/support/active_record/mysql_setup.rb
database_cleaner-0.9.1 spec/support/active_record/mysql_setup.rb