diff --git a/README.markdown b/README.markdown index 6dce964..d674dd3 100644 --- a/README.markdown +++ b/README.markdown @@ -507,7 +507,7 @@ end DatabaseCleaner comes with safeguards against: * Running in production (checking for `ENV`, `RACK_ENV`, and `RAILS_ENV`) -* Running against a remote database (checking for a `DATABASE_URL` that does not include `localhost`) +* Running against a remote database (checking for a `DATABASE_URL` that does not include `localhost`, `.local` or `127.0.0.1`) Both safeguards can be disabled separately as follows. diff --git a/lib/database_cleaner/safeguard.rb b/lib/database_cleaner/safeguard.rb index 0c5e73d..55d04eb 100644 --- a/lib/database_cleaner/safeguard.rb +++ b/lib/database_cleaner/safeguard.rb @@ -15,7 +15,7 @@ module DatabaseCleaner end class RemoteDatabaseUrl - LOCAL = %w(localhost 127.0.0.1 sqlite3:) + LOCAL = %w(localhost .local 127.0.0.1 sqlite3:) def run raise Error::RemoteDatabaseUrl if !skip? && given? diff --git a/spec/database_cleaner/safeguard_spec.rb b/spec/database_cleaner/safeguard_spec.rb index fa280a8..c2de148 100644 --- a/spec/database_cleaner/safeguard_spec.rb +++ b/spec/database_cleaner/safeguard_spec.rb @@ -28,6 +28,14 @@ module DatabaseCleaner end end + describe 'to a local tld url' do + let(:database_url) { 'postgres://postgres.local' } + + it 'does not raise' do + expect { cleaner.start }.to_not raise_error + end + end + describe 'to a 127.0.0.1 url' do let(:database_url) { 'postgres://127.0.0.1' }