Methods
S
T
Instance Public methods
setup()
# File activerecord/test/cases/tasks/mysql_rake_test.rb, line 6
def setup
  @connection    = stub(:create_database => true)
  @configuration = {
    'adapter'  => 'mysql',
    'database' => 'my-app-db'
  }

  ActiveRecord::Base.stubs(:connection).returns(@connection)
  ActiveRecord::Base.stubs(:establish_connection).returns(true)
end
test_create_when_database_exists_outputs_info_to_stderr()
# File activerecord/test/cases/tasks/mysql_rake_test.rb, line 58
def test_create_when_database_exists_outputs_info_to_stderr
  $stderr.expects(:puts).with("my-app-db already exists").once

  ActiveRecord::Base.connection.stubs(:create_database).raises(
    ActiveRecord::StatementInvalid.new("Can't create database 'dev'; database exists:")
  )

  ActiveRecord::Tasks::DatabaseTasks.create @configuration
end
test_creates_database_with_default_encoding_and_collation()
# File activerecord/test/cases/tasks/mysql_rake_test.rb, line 24
def test_creates_database_with_default_encoding_and_collation
  @connection.expects(:create_database).
    with('my-app-db', charset: 'utf8', collation: 'utf8_unicode_ci')

  ActiveRecord::Tasks::DatabaseTasks.create @configuration
end
test_creates_database_with_given_collation_and_no_encoding()
# File activerecord/test/cases/tasks/mysql_rake_test.rb, line 45
def test_creates_database_with_given_collation_and_no_encoding
  @connection.expects(:create_database).
    with('my-app-db', collation: 'latin1_swedish_ci')

  ActiveRecord::Tasks::DatabaseTasks.create @configuration.merge('collation' => 'latin1_swedish_ci')
end
test_creates_database_with_given_encoding_and_default_collation()
# File activerecord/test/cases/tasks/mysql_rake_test.rb, line 31
def test_creates_database_with_given_encoding_and_default_collation
  @connection.expects(:create_database).
    with('my-app-db', charset: 'utf8', collation: 'utf8_unicode_ci')

  ActiveRecord::Tasks::DatabaseTasks.create @configuration.merge('encoding' => 'utf8')
end
test_creates_database_with_given_encoding_and_no_collation()
# File activerecord/test/cases/tasks/mysql_rake_test.rb, line 38
def test_creates_database_with_given_encoding_and_no_collation
  @connection.expects(:create_database).
    with('my-app-db', charset: 'latin1')

  ActiveRecord::Tasks::DatabaseTasks.create @configuration.merge('encoding' => 'latin1')
end
test_establishes_connection_to_database()
# File activerecord/test/cases/tasks/mysql_rake_test.rb, line 52
def test_establishes_connection_to_database
  ActiveRecord::Base.expects(:establish_connection).with(@configuration)

  ActiveRecord::Tasks::DatabaseTasks.create @configuration
end
test_establishes_connection_without_database()
# File activerecord/test/cases/tasks/mysql_rake_test.rb, line 17
def test_establishes_connection_without_database
  ActiveRecord::Base.expects(:establish_connection).
    with('adapter' => 'mysql', 'database' => nil)

  ActiveRecord::Tasks::DatabaseTasks.create @configuration
end