memory_test_fix 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
data/README ADDED
@@ -0,0 +1,51 @@
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
+ Install the gem:
9
+
10
+ gem install memory_test_fix
11
+
12
+ In your config/environments.rb, use:
13
+
14
+ config.gem 'memory_test_fix'
15
+
16
+ In your database.yml, use:
17
+
18
+ test:
19
+ adapter: sqlite3
20
+ database: ":memory:"
21
+
22
+ It runs much faster!
23
+
24
+ You can also adjust the verbosity of the output:
25
+
26
+ test:
27
+ adapter: sqlite3
28
+ database: ":memory:"
29
+ verbosity: silent
30
+
31
+ You can also use this with other (testing) environments, not just 'test'.
32
+
33
+ == Authors
34
+
35
+ Chris Roos
36
+
37
+ Adapted by Geoffrey Grosenbach, http://nubyonrails.com
38
+
39
+ Verbosity patch by Kakutani Shintaro
40
+
41
+ Adapted as GemPlugin by Matijs van Zuijlen
42
+
43
+ Support for environments besides 'test' by Erik Hanson & Matt Scilipoti
44
+
45
+ == Changelog
46
+
47
+ * Supports environments besides 'test' (cucumber, etc)
48
+ * Updated to work as a GemPlugin
49
+ * Updated to look for either so it works with Rails 1.2 and also older versions
50
+ * Updated to use ActiveRecord::ConnectionAdapters::SQLite3Adapter for Rails 1.2
51
+
data/init.rb ADDED
@@ -0,0 +1 @@
1
+ require File.dirname(__FILE__) + "/rails/init"
@@ -0,0 +1,42 @@
1
+ # Update: Looks for the SQLite and SQLite3 adapters for
2
+ # compatibility with Rails 1.2.2 and also older versions.
3
+ def in_memory_database?
4
+ if (Rails::Configuration.new.database_configuration[Rails.env]['database'] == ':memory:' or
5
+ Rails::Configuration.new.database_configuration[Rails.env]['dbfile'] == ':memory:')
6
+ begin
7
+ if ActiveRecord::Base.connection.class == ActiveRecord::ConnectionAdapters::SQLite3Adapter
8
+ return true
9
+ end
10
+ rescue NameError => e
11
+ if ActiveRecord::Base.connection.class == ActiveRecord::ConnectionAdapters::SQLiteAdapter
12
+ return true
13
+ end
14
+ end
15
+ end
16
+ false
17
+ end
18
+
19
+ def verbosity
20
+ Rails::Configuration.new.database_configuration['test']['verbosity']
21
+ end
22
+
23
+ def inform_using_in_memory
24
+ puts "Creating sqlite :memory: database"
25
+ end
26
+
27
+ if in_memory_database?
28
+ load_schema = lambda {
29
+ load "#{RAILS_ROOT}/db/schema.rb" # use db agnostic schema by default
30
+ # ActiveRecord::Migrator.up('db/migrate') # use migrations
31
+ }
32
+ case verbosity
33
+ when "silent"
34
+ silence_stream(STDOUT, &load_schema)
35
+ when "quiet"
36
+ inform_using_in_memory
37
+ silence_stream(STDOUT, &load_schema)
38
+ else
39
+ inform_using_in_memory
40
+ load_schema.call
41
+ end
42
+ end
@@ -0,0 +1,16 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = "memory_test_fix"
3
+ s.version = "0.1.3"
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
+ "Erik Hanson and Matt Scilipoti", "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,70 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: memory_test_fix
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 1
8
+ - 3
9
+ version: 0.1.3
10
+ platform: ruby
11
+ authors:
12
+ - Chris Roos
13
+ - Geoffrey Grosenbach
14
+ - Kakutani Shintaro
15
+ - Erik Hanson and Matt Scilipoti
16
+ - Matijs van Zuijlen
17
+ autorequire:
18
+ bindir: bin
19
+ cert_chain: []
20
+
21
+ date: 2010-06-26 00:00:00 +02:00
22
+ default_executable:
23
+ dependencies: []
24
+
25
+ description:
26
+ email: matijs@matijs.net
27
+ executables: []
28
+
29
+ extensions: []
30
+
31
+ extra_rdoc_files:
32
+ - README
33
+ files:
34
+ - init.rb
35
+ - rails/init.rb
36
+ - lib/memory_test_fix.rb
37
+ - README
38
+ - memory_test_fix.gemspec
39
+ has_rdoc: true
40
+ homepage: http://wiki.github.com/mvz/memory_test_fix
41
+ licenses: []
42
+
43
+ post_install_message:
44
+ rdoc_options: []
45
+
46
+ require_paths:
47
+ - lib
48
+ required_ruby_version: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ segments:
53
+ - 0
54
+ version: "0"
55
+ required_rubygems_version: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ segments:
60
+ - 0
61
+ version: "0"
62
+ requirements: []
63
+
64
+ rubyforge_project:
65
+ rubygems_version: 1.3.6
66
+ signing_key:
67
+ specification_version: 3
68
+ summary: Makes SQLite3 memory tests possible by preloading the schema.
69
+ test_files: []
70
+