class ActiveRecord::ConnectionAdapters::ConnectionSpecification::ResolverTest
Public Instance Methods
resolve(spec, config = {})
click to toggle source
# File activerecord/test/cases/connection_specification/resolver_test.rb, line 9 def resolve(spec, config = {}) Resolver.new(config).resolve(spec) end
spec(spec, config = {})
click to toggle source
# File activerecord/test/cases/connection_specification/resolver_test.rb, line 13 def spec(spec, config = {}) Resolver.new(config).spec(spec) end
test_encoded_password()
click to toggle source
# File activerecord/test/cases/connection_specification/resolver_test.rb, line 89 def test_encoded_password password = "am@z1ng_p@ssw0rd#!" encoded_password = URI.encode_www_form_component(password) spec = resolve "abstract://foo:#{encoded_password}@localhost/bar" assert_equal password, spec["password"] end
test_spec_name_on_key_lookup()
click to toggle source
# File activerecord/test/cases/connection_specification/resolver_test.rb, line 125 def test_spec_name_on_key_lookup spec = spec(:readonly, "readonly" => { "adapter" => "sqlite3" }) assert_equal "readonly", spec.name end
test_spec_name_with_inline_config()
click to toggle source
# File activerecord/test/cases/connection_specification/resolver_test.rb, line 130 def test_spec_name_with_inline_config spec = spec("adapter" => "sqlite3") assert_equal "primary", spec.name, "should default to primary id" end
test_url_absolute_path_for_sqlite3()
click to toggle source
# File activerecord/test/cases/connection_specification/resolver_test.rb, line 101 def test_url_absolute_path_for_sqlite3 spec = resolve "sqlite3:/foo_test" assert_equal("/foo_test", spec["database"]) end
test_url_from_environment()
click to toggle source
The abstract adapter is used simply to bypass the bit of code that checks that the adapter file can be required in.
# File activerecord/test/cases/connection_specification/resolver_test.rb, line 28 def test_url_from_environment spec = resolve :production, "production" => "abstract://foo?encoding=utf8" assert_equal({ "adapter" => "abstract", "host" => "foo", "encoding" => "utf8", "name" => "production" }, spec) end
test_url_host_db()
click to toggle source
# File activerecord/test/cases/connection_specification/resolver_test.rb, line 71 def test_url_host_db spec = resolve "abstract://foo/bar?encoding=utf8" assert_equal({ "adapter" => "abstract", "database" => "bar", "host" => "foo", "encoding" => "utf8" }, spec) end
test_url_host_no_db()
click to toggle source
# File activerecord/test/cases/connection_specification/resolver_test.rb, line 57 def test_url_host_no_db spec = resolve "abstract://foo?encoding=utf8" assert_equal({ "adapter" => "abstract", "host" => "foo", "encoding" => "utf8" }, spec) end
test_url_invalid_adapter()
click to toggle source
# File activerecord/test/cases/connection_specification/resolver_test.rb, line 17 def test_url_invalid_adapter error = assert_raises(LoadError) do spec "ridiculous://foo?encoding=utf8" end assert_match "Could not load 'active_record/connection_adapters/ridiculous_adapter'", error.message end
test_url_memory_db_for_sqlite3()
click to toggle source
# File activerecord/test/cases/connection_specification/resolver_test.rb, line 111 def test_url_memory_db_for_sqlite3 spec = resolve "sqlite3::memory:" assert_equal(":memory:", spec["database"]) end
test_url_missing_scheme()
click to toggle source
# File activerecord/test/cases/connection_specification/resolver_test.rb, line 65 def test_url_missing_scheme spec = resolve "foo" assert_equal({ "database" => "foo" }, spec) end
test_url_port()
click to toggle source
# File activerecord/test/cases/connection_specification/resolver_test.rb, line 80 def test_url_port spec = resolve "abstract://foo:123?encoding=utf8" assert_equal({ "adapter" => "abstract", "port" => 123, "host" => "foo", "encoding" => "utf8" }, spec) end
test_url_relative_path_for_sqlite3()
click to toggle source
# File activerecord/test/cases/connection_specification/resolver_test.rb, line 106 def test_url_relative_path_for_sqlite3 spec = resolve "sqlite3:foo_test" assert_equal("foo_test", spec["database"]) end
test_url_sub_key()
click to toggle source
# File activerecord/test/cases/connection_specification/resolver_test.rb, line 37 def test_url_sub_key spec = resolve :production, "production" => { "url" => "abstract://foo?encoding=utf8" } assert_equal({ "adapter" => "abstract", "host" => "foo", "encoding" => "utf8", "name" => "production" }, spec) end
test_url_sub_key_for_sqlite3()
click to toggle source
# File activerecord/test/cases/connection_specification/resolver_test.rb, line 116 def test_url_sub_key_for_sqlite3 spec = resolve :production, "production" => { "url" => "sqlite3:foo?encoding=utf8" } assert_equal({ "adapter" => "sqlite3", "database" => "foo", "encoding" => "utf8", "name" => "production" }, spec) end
test_url_sub_key_merges_correctly()
click to toggle source
# File activerecord/test/cases/connection_specification/resolver_test.rb, line 46 def test_url_sub_key_merges_correctly hash = { "url" => "abstract://foo?encoding=utf8&", "adapter" => "sqlite3", "host" => "bar", "pool" => "3" } spec = resolve :production, "production" => hash assert_equal({ "adapter" => "abstract", "host" => "foo", "encoding" => "utf8", "pool" => "3", "name" => "production" }, spec) end