Sha256: 3020371101d3b704de60f3665554774e132bd23904e16f4f15a4e35936e27a24

Contents?: true

Size: 753 Bytes

Versions: 3

Compression:

Stored size: 753 Bytes

Contents

require 'abstract_db_create'
require 'db/mysql'

class MysqlDbCreateTest < Test::Unit::TestCase
  include AbstractDbCreate

  def db_config
    MYSQL_CONFIG
  end

  def test_rake_db_create
    omit_unless find_executable?("mysql")
    Rake::Task["db:create"].invoke
    with_mysql do |mysql|
      mysql << "show databases where `Database` = '#{@db_name}';"
      mysql.close_write
      assert mysql.read =~ /#{@db_name}/m      
    end
  end

  def test_rake_db_test_purge
    Rake::Task["db:create"].invoke
    Rake::Task["db:test:purge"].invoke
  end
  
  private
  
  def with_mysql(args = nil)
    exec = "mysql -u #{db_config[:username]} --password=#{db_config[:password]} #{args}"
    IO.popen(exec, "r+") { |mysql| yield(mysql) }
  end
  
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
activerecord-jdbc-adapter-1.2.9.1 test/mysql_db_create_test.rb
activerecord-jdbc-adapter-1.3.0.beta1 test/db/mysql/db_create_test.rb
activerecord-jdbc-adapter-1.2.9 test/mysql_db_create_test.rb