Methods
- S
- T
-
- teardown,
- test_config_choose_database_url_if_exists,
- test_config_with_database_url_only,
- test_config_with_db_config_only,
- test_config_with_no_db_config,
- test_env,
- test_mysql,
- test_mysql_full,
- test_mysql_include_password,
- test_oracle,
- test_oracle_include_password,
- test_postgresql,
- test_postgresql_full,
- test_postgresql_include_password,
- test_print_help_long,
- test_print_help_short,
- test_rails_env_is_dev_when_argument_is_dev_and_dev_env_is_present,
- test_rails_env_is_development_when_argument_is_dev,
- test_sqlite,
- test_sqlite3,
- test_sqlite3_db_absolute_path,
- test_sqlite3_db_without_defined_rails_root,
- test_sqlite3_header,
- test_sqlite3_mode,
- test_unknown_command_line_client
Instance Public methods
setup()
Link
teardown()
Link
test_config_choose_database_url_if_exists()
Link
# File railties/test/commands/dbconsole_test.rb, line 61 def test_config_choose_database_url_if_exists host = "database-url-host.com" ENV['DATABASE_URL'] = "postgresql://foo:bar@#{host}:9000/foo_test?pool=5&timeout=3000" sample_config = { "test" => { "adapter" => "postgresql", "host" => "not-the-#{host}", "port" => 9000, "database" => "foo_test", "username" => "foo", "password" => "bar", "pool" => "5", "timeout" => "3000" } } app_db_config(sample_config) do assert_equal host, Rails::DBConsole.new.config["host"] end end
test_config_with_database_url_only()
Link
# File railties/test/commands/dbconsole_test.rb, line 43 def test_config_with_database_url_only ENV['DATABASE_URL'] = 'postgresql://foo:bar@localhost:9000/foo_test?pool=5&timeout=3000' expected = { "adapter" => "postgresql", "host" => "localhost", "port" => 9000, "database" => "foo_test", "username" => "foo", "password" => "bar", "pool" => "5", "timeout" => "3000" }.sort app_db_config(nil) do assert_equal expected, Rails::DBConsole.new.config.sort end end
test_config_with_db_config_only()
Link
# File railties/test/commands/dbconsole_test.rb, line 17 def test_config_with_db_config_only config_sample = { "test"=> { "adapter"=> "sqlite3", "host"=> "localhost", "port"=> "9000", "database"=> "foo_test", "user"=> "foo", "password"=> "bar", "pool"=> "5", "timeout"=> "3000" } } app_db_config(config_sample) do assert_equal config_sample["test"], Rails::DBConsole.new.config end end
test_config_with_no_db_config()
Link
test_env()
Link
# File railties/test/commands/dbconsole_test.rb, line 81 def test_env assert_equal "test", Rails::DBConsole.new.environment ENV['RAILS_ENV'] = nil ENV['RACK_ENV'] = nil Rails.stub(:respond_to?, false) do assert_equal "development", Rails::DBConsole.new.environment ENV['RACK_ENV'] = "rack_env" assert_equal "rack_env", Rails::DBConsole.new.environment ENV['RAILS_ENV'] = "rails_env" assert_equal "rails_env", Rails::DBConsole.new.environment end ensure ENV['RAILS_ENV'] = "test" ENV['RACK_ENV'] = nil end
test_mysql()
Link
test_mysql_full()
Link
# File railties/test/commands/dbconsole_test.rb, line 125 def test_mysql_full start(adapter: 'mysql', database: 'db', host: 'locahost', port: 1234, socket: 'socket', username: 'user', password: 'qwerty', encoding: 'UTF-8') assert !aborted assert_equal [%w[mysql mysql5], '--host=locahost', '--port=1234', '--socket=socket', '--user=user', '--default-character-set=UTF-8', '-p', 'db'], dbconsole.find_cmd_and_exec_args end
test_mysql_include_password()
Link
# File railties/test/commands/dbconsole_test.rb, line 131 def test_mysql_include_password start({adapter: 'mysql', database: 'db', username: 'user', password: 'qwerty'}, ['-p']) assert !aborted assert_equal [%w[mysql mysql5], '--user=user', '--password=qwerty', 'db'], dbconsole.find_cmd_and_exec_args end
test_oracle()
Link
test_oracle_include_password()
Link
# File railties/test/commands/dbconsole_test.rb, line 204 def test_oracle_include_password start({adapter: 'oracle', database: 'db', username: 'user', password: 'secret'}, ['-p']) assert !aborted assert_equal ['sqlplus', 'user/secret@db'], dbconsole.find_cmd_and_exec_args end
test_postgresql()
Link
test_postgresql_full()
Link
# File railties/test/commands/dbconsole_test.rb, line 143 def test_postgresql_full start(adapter: 'postgresql', database: 'db', username: 'user', password: 'q1w2e3', host: 'host', port: 5432) assert !aborted assert_equal ['psql', 'db'], dbconsole.find_cmd_and_exec_args assert_equal 'user', ENV['PGUSER'] assert_equal 'host', ENV['PGHOST'] assert_equal '5432', ENV['PGPORT'] assert_not_equal 'q1w2e3', ENV['PGPASSWORD'] end
test_postgresql_include_password()
Link
# File railties/test/commands/dbconsole_test.rb, line 153 def test_postgresql_include_password start({adapter: 'postgresql', database: 'db', username: 'user', password: 'q1w2e3'}, ['-p']) assert !aborted assert_equal ['psql', 'db'], dbconsole.find_cmd_and_exec_args assert_equal 'user', ENV['PGUSER'] assert_equal 'q1w2e3', ENV['PGPASSWORD'] end
test_print_help_long()
Link
test_print_help_short()
Link
test_rails_env_is_dev_when_argument_is_dev_and_dev_env_is_present()
Link
# File railties/test/commands/dbconsole_test.rb, line 110 def test_rails_env_is_dev_when_argument_is_dev_and_dev_env_is_present dbconsole = Rails::DBConsole.new dbconsole.stub(:available_environments, ['dev']) do options = dbconsole.send(:parse_arguments, ['dev']) assert_match('dev', options[:environment]) end end
test_rails_env_is_development_when_argument_is_dev()
Link
# File railties/test/commands/dbconsole_test.rb, line 101 def test_rails_env_is_development_when_argument_is_dev dbconsole = Rails::DBConsole.new dbconsole.stub(:available_environments, ['development', 'test']) do options = dbconsole.send(:parse_arguments, ['dev']) assert_match('development', options[:environment]) end end
test_sqlite()
Link
test_sqlite3()
Link
test_sqlite3_db_absolute_path()
Link
test_sqlite3_db_without_defined_rails_root()
Link
# File railties/test/commands/dbconsole_test.rb, line 190 def test_sqlite3_db_without_defined_rails_root Rails.stub(:respond_to?, false) do start(adapter: 'sqlite3', database: 'config/db.sqlite3') assert !aborted assert_equal ['sqlite3', Rails.root.join('../config/db.sqlite3').to_s], dbconsole.find_cmd_and_exec_args end end
test_sqlite3_header()
Link
test_sqlite3_mode()
Link
# File railties/test/commands/dbconsole_test.rb, line 173 def test_sqlite3_mode start({adapter: 'sqlite3', database: 'db.sqlite3'}, ['--mode', 'html']) assert !aborted assert_equal ['sqlite3', '-html', Rails.root.join('db.sqlite3').to_s], dbconsole.find_cmd_and_exec_args end