mvz-memory_test_fix 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README ADDED
@@ -0,0 +1,38 @@
1
+ MemoryTestFix
2
+ =============
3
+
4
+ A simple fix to run tests with sqlite. From example at
5
+
6
+ http://blog.seagul.co.uk/articles/2006/02/08/in-memory-sqlite-database-for-rails-testing
7
+
8
+ In your database.yml, use
9
+
10
+ test:
11
+ adapter: sqlite3
12
+ database: ":memory:"
13
+
14
+ It runs much faster!
15
+
16
+ You can also adjust the verbosity of the output:
17
+
18
+ test:
19
+ adapter: sqlite3
20
+ database: ":memory:"
21
+ verbosity: silent
22
+
23
+ == Authors
24
+
25
+ Chris Roos
26
+
27
+ Adapted by Geoffrey Grosenbach, http://nubyonrails.com
28
+
29
+ Verbosity patch by Kakutani Shintaro
30
+
31
+ Adapted as GemPlugin by Matijs van Zuijlen
32
+
33
+ == Changelog
34
+
35
+ * Updated to work as a GemPlugin
36
+ * Updated to look for either so it works with Rails 1.2 and also older versions
37
+ * Updated to use ActiveRecord::ConnectionAdapters::SQLite3Adapter for Rails 1.2
38
+
data/init.rb ADDED
@@ -0,0 +1 @@
1
+ require File.dirname(__FILE__) + "/rails/init"
@@ -0,0 +1,44 @@
1
+
2
+ # Update: Looks for the SQLite and SQLite3 adapters for
3
+ # compatibility with Rails 1.2.2 and also older versions.
4
+ def in_memory_database?
5
+ if ENV["RAILS_ENV"] == "test" and
6
+ (Rails::Configuration.new.database_configuration['test']['database'] == ':memory:' or
7
+ Rails::Configuration.new.database_configuration['test']['dbfile'] == ':memory:')
8
+ begin
9
+ if ActiveRecord::Base.connection.class == ActiveRecord::ConnectionAdapters::SQLite3Adapter
10
+ return true
11
+ end
12
+ rescue NameError => e
13
+ if ActiveRecord::Base.connection.class == ActiveRecord::ConnectionAdapters::SQLiteAdapter
14
+ return true
15
+ end
16
+ end
17
+ end
18
+ false
19
+ end
20
+
21
+ def verbosity
22
+ Rails::Configuration.new.database_configuration['test']['verbosity']
23
+ end
24
+
25
+ def inform_using_in_memory
26
+ puts "Creating sqlite :memory: database"
27
+ end
28
+
29
+ if in_memory_database?
30
+ load_schema = lambda {
31
+ load "#{RAILS_ROOT}/db/schema.rb" # use db agnostic schema by default
32
+ # ActiveRecord::Migrator.up('db/migrate') # use migrations
33
+ }
34
+ case verbosity
35
+ when "silent"
36
+ silence_stream(STDOUT, &load_schema)
37
+ when "quiet"
38
+ inform_using_in_memory
39
+ silence_stream(STDOUT, &load_schema)
40
+ else
41
+ inform_using_in_memory
42
+ load_schema.call
43
+ end
44
+ end
@@ -0,0 +1,16 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = "memory_test_fix"
3
+ s.version = "0.1.1"
4
+
5
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
6
+ s.authors = ["Chris Roos", "Geoffrey Grosenbach", "Kakutani Shintaro",
7
+ "Matijs van Zuijlen"]
8
+ s.email = "matijs@matijs.net"
9
+ s.summary = "Makes SQLite3 memory tests possible by preloading the schema."
10
+ s.homepage = "http://wiki.github.com/mvz/memory_test_fix"
11
+ s.require_paths = ["lib"]
12
+ s.files = ["init.rb", "rails/init.rb", "lib/memory_test_fix.rb", "README", "memory_test_fix.gemspec"]
13
+ s.has_rdoc = true
14
+ s.extra_rdoc_files = ['README']
15
+ s.rubygems_version = %q{1.2.0}
16
+ end
data/rails/init.rb ADDED
@@ -0,0 +1,2 @@
1
+
2
+ require 'memory_test_fix'
metadata ADDED
@@ -0,0 +1,60 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mvz-memory_test_fix
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Chris Roos
8
+ - Geoffrey Grosenbach
9
+ - Kakutani Shintaro
10
+ - Matijs van Zuijlen
11
+ autorequire:
12
+ bindir: bin
13
+ cert_chain: []
14
+
15
+ date: 2009-02-05 00:00:00 -08:00
16
+ default_executable:
17
+ dependencies: []
18
+
19
+ description:
20
+ email: matijs@matijs.net
21
+ executables: []
22
+
23
+ extensions: []
24
+
25
+ extra_rdoc_files:
26
+ - README
27
+ files:
28
+ - init.rb
29
+ - rails/init.rb
30
+ - lib/memory_test_fix.rb
31
+ - README
32
+ - memory_test_fix.gemspec
33
+ has_rdoc: true
34
+ homepage: http://wiki.github.com/mvz/memory_test_fix
35
+ post_install_message:
36
+ rdoc_options: []
37
+
38
+ require_paths:
39
+ - lib
40
+ required_ruby_version: !ruby/object:Gem::Requirement
41
+ requirements:
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ version: "0"
45
+ version:
46
+ required_rubygems_version: !ruby/object:Gem::Requirement
47
+ requirements:
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ version: "0"
51
+ version:
52
+ requirements: []
53
+
54
+ rubyforge_project:
55
+ rubygems_version: 1.2.0
56
+ signing_key:
57
+ specification_version: 2
58
+ summary: Makes SQLite3 memory tests possible by preloading the schema.
59
+ test_files: []
60
+