memory_test_fix 0.2.0 → 0.2.2
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.md +55 -0
- data/lib/memory_test_fix.rb +23 -16
- data/memory_test_fix.gemspec +22 -7
- metadata +28 -46
- data/README +0 -51
data/README.md
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
# MemoryTestFix
|
2
|
+
|
3
|
+
A simple fix to run your Rails tests with sqlite. From the
|
4
|
+
[example by Chris Roos](http://blog.seagul.co.uk/articles/2006/02/08/in-memory-sqlite-database-for-rails-testing).
|
5
|
+
|
6
|
+
## Usage
|
7
|
+
|
8
|
+
Add the gem to your bundle by adding
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
gem 'memory_test_fix'
|
12
|
+
```
|
13
|
+
|
14
|
+
to your `Gemfile`
|
15
|
+
|
16
|
+
|
17
|
+
In your database.yml, use:
|
18
|
+
|
19
|
+
```yaml
|
20
|
+
test:
|
21
|
+
adapter: sqlite3
|
22
|
+
database: ":memory:"
|
23
|
+
```
|
24
|
+
|
25
|
+
It runs much faster!
|
26
|
+
|
27
|
+
You can also adjust the verbosity of the output:
|
28
|
+
|
29
|
+
```yaml
|
30
|
+
test:
|
31
|
+
adapter: sqlite3
|
32
|
+
database: ":memory:"
|
33
|
+
verbosity: silent
|
34
|
+
```
|
35
|
+
|
36
|
+
You can also use this with other (testing) environments, not just 'test'.
|
37
|
+
|
38
|
+
## Rails Versions
|
39
|
+
|
40
|
+
This gem is compatible with Rails 3 and Rails 2.3. If you're using an
|
41
|
+
older version of Rails, use the 0.1.x version of this gem.
|
42
|
+
|
43
|
+
## Authors
|
44
|
+
|
45
|
+
MemoryTestFix is maintained by [Matijs van Zuijlen](http://www.matijs.net/)
|
46
|
+
|
47
|
+
The following people have contributed to this gem:
|
48
|
+
|
49
|
+
* [Original hack](http://chrisroos.co.uk/blog/2006-02-08-in-memory-sqlite-database-for-rails-testing) by Chris Roos
|
50
|
+
* Adapted by [Geoffrey Grosenbach](http://nubyonrails.com)
|
51
|
+
* Verbosity patch by Kakutani Shintaro
|
52
|
+
* Adapted as GemPlugin by Matijs van Zuijlen
|
53
|
+
* Support for environments besides 'test' by Erik Hanson & Matt Scilipoti
|
54
|
+
* Support for Rails 3 by Greg Weber
|
55
|
+
* Fix for Rails 3.2 by Stephan Zalewski
|
data/lib/memory_test_fix.rb
CHANGED
@@ -1,19 +1,22 @@
|
|
1
1
|
module MemoryTestFix
|
2
2
|
def self.in_memory_database?
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
3
|
+
in_memory? && sqlite3?
|
4
|
+
end
|
5
|
+
|
6
|
+
def self.in_memory?
|
7
|
+
configuration[:database] == ':memory:' || configuration[:dbfile] == ':memory:'
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.sqlite3?
|
11
|
+
configuration[:adapter] == 'sqlite3'
|
9
12
|
end
|
10
13
|
|
11
14
|
def self.configuration
|
12
|
-
Rails.configuration.database_configuration[Rails.env]
|
15
|
+
Rails.configuration.database_configuration[Rails.env].with_indifferent_access
|
13
16
|
end
|
14
17
|
|
15
18
|
def self.verbosity
|
16
|
-
configuration[
|
19
|
+
configuration[:verbosity]
|
17
20
|
end
|
18
21
|
|
19
22
|
def self.inform_using_in_memory
|
@@ -23,23 +26,27 @@ module MemoryTestFix
|
|
23
26
|
def self.init_schema
|
24
27
|
if in_memory_database?
|
25
28
|
load_schema = lambda {
|
26
|
-
|
27
|
-
|
29
|
+
load "#{Rails.root}/db/schema.rb" # use db agnostic schema by default
|
30
|
+
# ActiveRecord::Migrator.up('db/migrate') # use migrations
|
28
31
|
}
|
29
32
|
case verbosity
|
30
33
|
when "silent"
|
31
|
-
|
34
|
+
silence_stream(STDOUT, &load_schema)
|
32
35
|
when "quiet"
|
33
|
-
|
34
|
-
|
36
|
+
inform_using_in_memory
|
37
|
+
silence_stream(STDOUT, &load_schema)
|
35
38
|
else
|
36
|
-
|
37
|
-
|
39
|
+
inform_using_in_memory
|
40
|
+
load_schema.call
|
38
41
|
end
|
39
42
|
end
|
40
43
|
end
|
41
44
|
end
|
42
45
|
|
43
|
-
ActiveSupport.on_load
|
46
|
+
if ActiveSupport.respond_to? :on_load
|
47
|
+
ActiveSupport.on_load(:after_initialize) do
|
48
|
+
MemoryTestFix.init_schema
|
49
|
+
end
|
50
|
+
else
|
44
51
|
MemoryTestFix.init_schema
|
45
52
|
end
|
data/memory_test_fix.gemspec
CHANGED
@@ -1,16 +1,31 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "memory_test_fix"
|
3
|
-
s.version = "0.2.
|
3
|
+
s.version = "0.2.2"
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
if s.respond_to? :required_rubygems_version=
|
6
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0")
|
7
|
+
end
|
8
|
+
|
9
|
+
s.authors = [ "Matijs van Zuijlen",
|
10
|
+
"Chris Roos",
|
11
|
+
"Geoffrey Grosenbach",
|
12
|
+
"Kakutani Shintaro",
|
13
|
+
"Erik Hanson and Matt Scilipoti",
|
14
|
+
"Greg Weber",
|
15
|
+
"Stephan Zalewski" ]
|
8
16
|
s.email = "matijs@matijs.net"
|
9
|
-
|
17
|
+
|
18
|
+
s.summary = "Use SQLite3 in-memory database for Rails tests."
|
19
|
+
s.description = "Makes use of SQLite3 in-memory database possible for your Rails tests by preloading the schema."
|
20
|
+
|
10
21
|
s.homepage = "http://wiki.github.com/mvz/memory_test_fix"
|
11
22
|
s.require_paths = ["lib"]
|
12
|
-
s.files = ["init.rb",
|
23
|
+
s.files = ["init.rb",
|
24
|
+
"rails/init.rb",
|
25
|
+
"lib/memory_test_fix.rb",
|
26
|
+
"README.md",
|
27
|
+
"memory_test_fix.gemspec"]
|
13
28
|
s.has_rdoc = true
|
14
|
-
s.extra_rdoc_files = ['README']
|
29
|
+
s.extra_rdoc_files = ['README.md']
|
15
30
|
s.rubygems_version = %q{1.2.0}
|
16
31
|
end
|
metadata
CHANGED
@@ -1,76 +1,58 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: memory_test_fix
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 2
|
9
|
-
- 0
|
10
|
-
version: 0.2.0
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.2
|
5
|
+
prerelease:
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
8
|
+
- Matijs van Zuijlen
|
13
9
|
- Chris Roos
|
14
10
|
- Geoffrey Grosenbach
|
15
11
|
- Kakutani Shintaro
|
16
12
|
- Erik Hanson and Matt Scilipoti
|
17
|
-
- Matijs van Zuijlen
|
18
13
|
- Greg Weber
|
14
|
+
- Stephan Zalewski
|
19
15
|
autorequire:
|
20
16
|
bindir: bin
|
21
17
|
cert_chain: []
|
22
|
-
|
23
|
-
date: 2011-01-06 00:00:00 +01:00
|
24
|
-
default_executable:
|
18
|
+
date: 2013-02-02 00:00:00.000000000 Z
|
25
19
|
dependencies: []
|
26
|
-
|
27
|
-
|
20
|
+
description: Makes use of SQLite3 in-memory database possible for your Rails tests
|
21
|
+
by preloading the schema.
|
28
22
|
email: matijs@matijs.net
|
29
23
|
executables: []
|
30
|
-
|
31
24
|
extensions: []
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
files:
|
25
|
+
extra_rdoc_files:
|
26
|
+
- README.md
|
27
|
+
files:
|
36
28
|
- init.rb
|
37
29
|
- rails/init.rb
|
38
30
|
- lib/memory_test_fix.rb
|
39
|
-
- README
|
31
|
+
- README.md
|
40
32
|
- memory_test_fix.gemspec
|
41
|
-
has_rdoc: true
|
42
33
|
homepage: http://wiki.github.com/mvz/memory_test_fix
|
43
34
|
licenses: []
|
44
|
-
|
45
35
|
post_install_message:
|
46
36
|
rdoc_options: []
|
47
|
-
|
48
|
-
require_paths:
|
37
|
+
require_paths:
|
49
38
|
- lib
|
50
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
39
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
51
40
|
none: false
|
52
|
-
requirements:
|
53
|
-
- -
|
54
|
-
- !ruby/object:Gem::Version
|
55
|
-
|
56
|
-
|
57
|
-
- 0
|
58
|
-
version: "0"
|
59
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
41
|
+
requirements:
|
42
|
+
- - ! '>='
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: '0'
|
45
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
60
46
|
none: false
|
61
|
-
requirements:
|
62
|
-
- -
|
63
|
-
- !ruby/object:Gem::Version
|
64
|
-
|
65
|
-
segments:
|
66
|
-
- 0
|
67
|
-
version: "0"
|
47
|
+
requirements:
|
48
|
+
- - ! '>='
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: '0'
|
68
51
|
requirements: []
|
69
|
-
|
70
52
|
rubyforge_project:
|
71
|
-
rubygems_version: 1.
|
53
|
+
rubygems_version: 1.8.23
|
72
54
|
signing_key:
|
73
55
|
specification_version: 3
|
74
|
-
summary:
|
56
|
+
summary: Use SQLite3 in-memory database for Rails tests.
|
75
57
|
test_files: []
|
76
|
-
|
58
|
+
has_rdoc: true
|
data/README
DELETED
@@ -1,51 +0,0 @@
|
|
1
|
-
MemoryTestFix
|
2
|
-
=============
|
3
|
-
|
4
|
-
A simple fix to run your Rails tests with sqlite. From the 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
|
-
== Rails Versions
|
34
|
-
|
35
|
-
Due to incompatibilities in the loading of gem plugins by Rails, this gem
|
36
|
-
only works with Rails 3 starting from version 0.2.0. If you're using an
|
37
|
-
older version of Rails, use the 0.1.x version of this gem.
|
38
|
-
|
39
|
-
== Authors
|
40
|
-
|
41
|
-
Chris Roos
|
42
|
-
|
43
|
-
Adapted by Geoffrey Grosenbach, http://nubyonrails.com
|
44
|
-
|
45
|
-
Verbosity patch by Kakutani Shintaro
|
46
|
-
|
47
|
-
Adapted as GemPlugin by Matijs van Zuijlen
|
48
|
-
|
49
|
-
Support for environments besides 'test' by Erik Hanson & Matt Scilipoti
|
50
|
-
|
51
|
-
Support for Rails 3 by Greg Weber
|