mirror of
https://github.com/TracksApp/tracks.git
synced 2026-02-03 06:21:49 +01:00
upgrade to memory_test_fix r171
git-svn-id: http://www.rousette.org.uk/svn/tracks-repos/trunk@417 a4c988fc-2ded-0310-b66e-134b36920a42
This commit is contained in:
parent
0da21e3b96
commit
59f5cea7b8
5 changed files with 91 additions and 0 deletions
29
tracks/vendor/plugins/memory_test_fix/README
vendored
Normal file
29
tracks/vendor/plugins/memory_test_fix/README
vendored
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
MemoryTestFix
|
||||
=============
|
||||
|
||||
A simple fix to run tests with sqlite. From example at
|
||||
|
||||
http://blog.seagul.co.uk/articles/2006/02/08/in-memory-sqlite-database-for-rails-testing
|
||||
|
||||
In your database.yml, use
|
||||
|
||||
test:
|
||||
adapter: sqlite3
|
||||
database: ":memory:"
|
||||
|
||||
It runs much faster!
|
||||
|
||||
You can also adjust the verbosity of the output:
|
||||
|
||||
test:
|
||||
adapter: sqlite3
|
||||
database: ":memory:"
|
||||
verbosity: silent
|
||||
|
||||
== Authors
|
||||
|
||||
Chris Roos
|
||||
|
||||
Adapted by Geoffrey Grosenbach, http://nubyonrails.com
|
||||
|
||||
Verbosity patch by Kakutani Shintaro
|
||||
22
tracks/vendor/plugins/memory_test_fix/Rakefile
vendored
Normal file
22
tracks/vendor/plugins/memory_test_fix/Rakefile
vendored
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
require 'rake'
|
||||
require 'rake/testtask'
|
||||
require 'rake/rdoctask'
|
||||
|
||||
desc 'Default: run unit tests.'
|
||||
task :default => :test
|
||||
|
||||
desc 'Test the memory_test_fix plugin.'
|
||||
Rake::TestTask.new(:test) do |t|
|
||||
t.libs << 'lib'
|
||||
t.pattern = 'test/**/*_test.rb'
|
||||
t.verbose = true
|
||||
end
|
||||
|
||||
desc 'Generate documentation for the memory_test_fix plugin.'
|
||||
Rake::RDocTask.new(:rdoc) do |rdoc|
|
||||
rdoc.rdoc_dir = 'rdoc'
|
||||
rdoc.title = 'MemoryTestFix'
|
||||
rdoc.options << '--line-numbers' << '--inline-source'
|
||||
rdoc.rdoc_files.include('README')
|
||||
rdoc.rdoc_files.include('lib/**/*.rb')
|
||||
end
|
||||
7
tracks/vendor/plugins/memory_test_fix/about.yml
vendored
Normal file
7
tracks/vendor/plugins/memory_test_fix/about.yml
vendored
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
author: Chris Roos
|
||||
summary: Makes SQLite3 memory tests possible by preloading the schema.
|
||||
homepage: http://blog.seagul.co.uk/articles/2006/02/08/in-memory-sqlite-database-for-rails-testing
|
||||
plugin: http://topfunky.net/svn/plugins/memory_test_fix
|
||||
license: MIT
|
||||
version: 0.1
|
||||
rails_version: 1.1+
|
||||
2
tracks/vendor/plugins/memory_test_fix/init.rb
vendored
Normal file
2
tracks/vendor/plugins/memory_test_fix/init.rb
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
|
||||
require 'memory_test_fix'
|
||||
31
tracks/vendor/plugins/memory_test_fix/lib/memory_test_fix.rb
vendored
Normal file
31
tracks/vendor/plugins/memory_test_fix/lib/memory_test_fix.rb
vendored
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
# MemoryTestFix
|
||||
def in_memory_database?
|
||||
ENV["RAILS_ENV"] == "test" and
|
||||
ActiveRecord::Base.connection.class == ActiveRecord::ConnectionAdapters::SQLiteAdapter and
|
||||
Rails::Configuration.new.database_configuration['test']['database'] == ':memory:'
|
||||
end
|
||||
|
||||
def verbosity
|
||||
Rails::Configuration.new.database_configuration['test']['verbosity']
|
||||
end
|
||||
|
||||
def inform_using_in_memory
|
||||
puts "Creating sqlite :memory: database"
|
||||
end
|
||||
|
||||
if in_memory_database?
|
||||
load_schema = lambda {
|
||||
load "#{RAILS_ROOT}/db/schema.rb" # use db agnostic schema by default
|
||||
# ActiveRecord::Migrator.up('db/migrate') # use migrations
|
||||
}
|
||||
case verbosity
|
||||
when "silent"
|
||||
silence_stream(STDOUT, &load_schema)
|
||||
when "quiet"
|
||||
inform_using_in_memory
|
||||
silence_stream(STDOUT, &load_schema)
|
||||
else
|
||||
inform_using_in_memory
|
||||
load_schema.call
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue