Methods
- S
- T
-
- teardown,
- test_create_when_database_exists_outputs_info_to_stderr,
- test_creates_database_with_default_encoding,
- test_creates_database_with_given_collation_and_ctype,
- test_creates_database_with_given_encoding,
- test_db_create_with_error_prints_message,
- test_establishes_connection_to_new_database,
- test_establishes_connection_to_postgresql_database,
- test_when_database_created_successfully_outputs_info_to_stdout
Instance Public methods
setup()
Link
# File activerecord/test/cases/tasks/postgresql_rake_test.rb, line 7 def setup @connection = stub(:create_database => true) @configuration = { 'adapter' => 'postgresql', 'database' => 'my-app-db' } ActiveRecord::Base.stubs(:connection).returns(@connection) ActiveRecord::Base.stubs(:establish_connection).returns(true) $stdout, @original_stdout = StringIO.new, $stdout $stderr, @original_stderr = StringIO.new, $stderr end
teardown()
Link
test_create_when_database_exists_outputs_info_to_stderr()
Link
# File activerecord/test/cases/tasks/postgresql_rake_test.rb, line 80 def test_create_when_database_exists_outputs_info_to_stderr ActiveRecord::Base.connection.stubs(:create_database).raises( ActiveRecord::Tasks::DatabaseAlreadyExists ) ActiveRecord::Tasks::DatabaseTasks.create @configuration assert_equal $stderr.string, "Database 'my-app-db' already exists\n" end
test_creates_database_with_default_encoding()
Link
# File activerecord/test/cases/tasks/postgresql_rake_test.rb, line 35 def test_creates_database_with_default_encoding @connection.expects(:create_database). with('my-app-db', @configuration.merge('encoding' => 'utf8')) ActiveRecord::Tasks::DatabaseTasks.create @configuration end
test_creates_database_with_given_collation_and_ctype()
Link
# File activerecord/test/cases/tasks/postgresql_rake_test.rb, line 50 def test_creates_database_with_given_collation_and_ctype @connection.expects(:create_database). with('my-app-db', @configuration.merge('encoding' => 'utf8', 'collation' => 'ja_JP.UTF8', 'ctype' => 'ja_JP.UTF8')) ActiveRecord::Tasks::DatabaseTasks.create @configuration. merge('collation' => 'ja_JP.UTF8', 'ctype' => 'ja_JP.UTF8') end
test_creates_database_with_given_encoding()
Link
# File activerecord/test/cases/tasks/postgresql_rake_test.rb, line 42 def test_creates_database_with_given_encoding @connection.expects(:create_database). with('my-app-db', @configuration.merge('encoding' => 'latin')) ActiveRecord::Tasks::DatabaseTasks.create @configuration. merge('encoding' => 'latin') end
test_db_create_with_error_prints_message()
Link
# File activerecord/test/cases/tasks/postgresql_rake_test.rb, line 64 def test_db_create_with_error_prints_message ActiveRecord::Base.stubs(:establish_connection).raises(Exception) $stderr.stubs(:puts).returns(true) $stderr.expects(:puts). with("Couldn't create database for #{@configuration.inspect}") assert_raises(Exception) { ActiveRecord::Tasks::DatabaseTasks.create @configuration } end
test_establishes_connection_to_new_database()
Link
test_establishes_connection_to_postgresql_database()
Link
# File activerecord/test/cases/tasks/postgresql_rake_test.rb, line 25 def test_establishes_connection_to_postgresql_database ActiveRecord::Base.expects(:establish_connection).with( 'adapter' => 'postgresql', 'database' => 'postgres', 'schema_search_path' => 'public' ) ActiveRecord::Tasks::DatabaseTasks.create @configuration end
test_when_database_created_successfully_outputs_info_to_stdout()
Link