Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix error message for AdapterNotFound in spec #37180

Merged
merged 1 commit into from Sep 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -185,7 +185,7 @@ def spec(config)
adapter_method = "#{spec[:adapter]}_connection"

unless ActiveRecord::Base.respond_to?(adapter_method)
raise AdapterNotFound, "database configuration specifies nonexistent #{spec.config[:adapter]} adapter"
raise AdapterNotFound, "database configuration specifies nonexistent #{spec[:adapter]} adapter"
end

ConnectionSpecification.new(spec.delete(:name) || "primary", spec, adapter_method)
Expand Down
Expand Up @@ -26,6 +26,14 @@ def test_url_invalid_adapter
assert_match "Could not load the 'ridiculous' Active Record adapter. Ensure that the adapter is spelled correctly in config/database.yml and that you've added the necessary adapter gem to your Gemfile.", error.message
end

def test_error_if_no_adapter_method
error = assert_raises(AdapterNotFound) do
spec "abstract://foo?encoding=utf8"
end

assert_match "database configuration specifies nonexistent abstract adapter", error.message
end

# The abstract adapter is used simply to bypass the bit of code that
# checks that the adapter file can be required in.

Expand Down