memory_test_fix 0.1.3 → 0.2.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  MemoryTestFix
2
2
  =============
3
3
 
4
- A simple fix to run tests with sqlite. From example at
4
+ A simple fix to run your Rails tests with sqlite. From the example at
5
5
 
6
6
  http://blog.seagul.co.uk/articles/2006/02/08/in-memory-sqlite-database-for-rails-testing
7
7
 
@@ -30,6 +30,12 @@ You can also adjust the verbosity of the output:
30
30
 
31
31
  You can also use this with other (testing) environments, not just 'test'.
32
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
+
33
39
  == Authors
34
40
 
35
41
  Chris Roos
@@ -42,10 +48,4 @@ Adapted as GemPlugin by Matijs van Zuijlen
42
48
 
43
49
  Support for environments besides 'test' by Erik Hanson & Matt Scilipoti
44
50
 
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
-
51
+ Support for Rails 3 by Greg Weber
@@ -1,42 +1,45 @@
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
1
+ module MemoryTestFix
2
+ def self.in_memory_database?
3
+ if (configuration['database'] == ':memory:' or configuration['dbfile'] == ':memory:')
7
4
  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
5
+ return true
13
6
  end
14
7
  end
8
+ false
15
9
  end
16
- false
17
- end
18
10
 
19
- def verbosity
20
- Rails::Configuration.new.database_configuration['test']['verbosity']
21
- end
11
+ def self.configuration
12
+ Rails.configuration.database_configuration[Rails.env]
13
+ end
22
14
 
23
- def inform_using_in_memory
24
- puts "Creating sqlite :memory: database"
25
- end
15
+ def self.verbosity
16
+ configuration['verbosity']
17
+ end
26
18
 
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
19
+ def self.inform_using_in_memory
20
+ puts "Creating sqlite :memory: database"
41
21
  end
22
+
23
+ def self.init_schema
24
+ if in_memory_database?
25
+ load_schema = lambda {
26
+ load "#{Rails.root}/db/schema.rb" # use db agnostic schema by default
27
+ # ActiveRecord::Migrator.up('db/migrate') # use migrations
28
+ }
29
+ case verbosity
30
+ when "silent"
31
+ silence_stream(STDOUT, &load_schema)
32
+ when "quiet"
33
+ inform_using_in_memory
34
+ silence_stream(STDOUT, &load_schema)
35
+ else
36
+ inform_using_in_memory
37
+ load_schema.call
38
+ end
39
+ end
40
+ end
41
+ end
42
+
43
+ ActiveSupport.on_load(:before_initialize) do
44
+ MemoryTestFix.init_schema
42
45
  end
@@ -1,10 +1,10 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "memory_test_fix"
3
- s.version = "0.1.3"
3
+ s.version = "0.2.0"
4
4
 
5
5
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
6
6
  s.authors = ["Chris Roos", "Geoffrey Grosenbach", "Kakutani Shintaro",
7
- "Erik Hanson and Matt Scilipoti", "Matijs van Zuijlen"]
7
+ "Erik Hanson and Matt Scilipoti", "Matijs van Zuijlen", "Greg Weber"]
8
8
  s.email = "matijs@matijs.net"
9
9
  s.summary = "Makes SQLite3 memory tests possible by preloading the schema."
10
10
  s.homepage = "http://wiki.github.com/mvz/memory_test_fix"
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: memory_test_fix
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 23
4
5
  prerelease: false
5
6
  segments:
6
7
  - 0
7
- - 1
8
- - 3
9
- version: 0.1.3
8
+ - 2
9
+ - 0
10
+ version: 0.2.0
10
11
  platform: ruby
11
12
  authors:
12
13
  - Chris Roos
@@ -14,11 +15,12 @@ authors:
14
15
  - Kakutani Shintaro
15
16
  - Erik Hanson and Matt Scilipoti
16
17
  - Matijs van Zuijlen
18
+ - Greg Weber
17
19
  autorequire:
18
20
  bindir: bin
19
21
  cert_chain: []
20
22
 
21
- date: 2010-06-26 00:00:00 +02:00
23
+ date: 2011-01-06 00:00:00 +01:00
22
24
  default_executable:
23
25
  dependencies: []
24
26
 
@@ -46,23 +48,27 @@ rdoc_options: []
46
48
  require_paths:
47
49
  - lib
48
50
  required_ruby_version: !ruby/object:Gem::Requirement
51
+ none: false
49
52
  requirements:
50
53
  - - ">="
51
54
  - !ruby/object:Gem::Version
55
+ hash: 3
52
56
  segments:
53
57
  - 0
54
58
  version: "0"
55
59
  required_rubygems_version: !ruby/object:Gem::Requirement
60
+ none: false
56
61
  requirements:
57
62
  - - ">="
58
63
  - !ruby/object:Gem::Version
64
+ hash: 3
59
65
  segments:
60
66
  - 0
61
67
  version: "0"
62
68
  requirements: []
63
69
 
64
70
  rubyforge_project:
65
- rubygems_version: 1.3.6
71
+ rubygems_version: 1.3.7
66
72
  signing_key:
67
73
  specification_version: 3
68
74
  summary: Makes SQLite3 memory tests possible by preloading the schema.