Module: Hanami::DB::Testing
- Defined in:
- lib/hanami/db/testing.rb
Constant Summary collapse
- DATABASE_NAME_SUFFIX =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Replaces development suffix in test mode
"_test"
Class Method Summary collapse
- .database_url(url) ⇒ Object private
Class Method Details
.database_url(url) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/hanami/db/testing.rb', line 23 def database_url(url) url = parse_url(url) case deconstruct_url(url) in { scheme: "sqlite", opaque: nil, path: } unless path.nil? url.path = database_filename(path) in { path: String => path } if path =~ DATABASE_NAME_MATCHER url.path = path.sub(DATABASE_NAME_MATCHER, DATABASE_NAME_SUFFIX) in { path: String => path } unless path.end_with?(DATABASE_NAME_SUFFIX) url.path << DATABASE_NAME_SUFFIX else # do nothing end stringify_url(url) end |