aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorSean Griffin <sean@seantheprogrammer.com>2015-12-16 12:02:12 -0700
committerSean Griffin <sean@seantheprogrammer.com>2015-12-16 12:03:40 -0700
commitf0f4f543c82db02d936df63215e2e95c3f871521 (patch)
treec0f270b80af8e3c0bc2c7bc7d69d06aff1eb04c0 /activerecord
parentb1c19eb05299fbae2a80beb4abacacc4b5340776 (diff)
downloadrails-f0f4f543c82db02d936df63215e2e95c3f871521.tar.gz
rails-f0f4f543c82db02d936df63215e2e95c3f871521.tar.bz2
rails-f0f4f543c82db02d936df63215e2e95c3f871521.zip
Fix test failure on Windows
When this test was run on Windows, the database file would still be in use, and `File.unlink` would fail. This would cause the temp directory to be unable to be removed, and error out. By disconnecting the connection when finished, we can avoid this error.
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/test/cases/adapters/sqlite3/sqlite3_create_folder_test.rb16
1 files changed, 10 insertions, 6 deletions
diff --git a/activerecord/test/cases/adapters/sqlite3/sqlite3_create_folder_test.rb b/activerecord/test/cases/adapters/sqlite3/sqlite3_create_folder_test.rb
index 887dcfc96c..9b675b804b 100644
--- a/activerecord/test/cases/adapters/sqlite3/sqlite3_create_folder_test.rb
+++ b/activerecord/test/cases/adapters/sqlite3/sqlite3_create_folder_test.rb
@@ -6,13 +6,17 @@ module ActiveRecord
class SQLite3CreateFolder < ActiveRecord::SQLite3TestCase
def test_sqlite_creates_directory
Dir.mktmpdir do |dir|
- dir = Pathname.new(dir)
- @conn = Base.sqlite3_connection :database => dir.join("db/foo.sqlite3"),
- :adapter => 'sqlite3',
- :timeout => 100
+ begin
+ dir = Pathname.new(dir)
+ @conn = Base.sqlite3_connection :database => dir.join("db/foo.sqlite3"),
+ :adapter => 'sqlite3',
+ :timeout => 100
- assert Dir.exist? dir.join('db')
- assert File.exist? dir.join('db/foo.sqlite3')
+ assert Dir.exist? dir.join('db')
+ assert File.exist? dir.join('db/foo.sqlite3')
+ ensure
+ @conn.disconnect! if @conn
+ end
end
end
end