memory_test_fix 1.5.0 → 1.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Changelog.md +5 -0
- data/fixtures/rails52_app/db/schema.rb +2 -3
- data/lib/memory_test_fix.rb +1 -1
- data/lib/memory_test_fix/schema_file_loader.rb +0 -1
- data/lib/memory_test_fix/schema_loader.rb +3 -3
- data/memory_test_fix.gemspec +25 -25
- data/spec/unit/memory_test_fix/schema_loader_spec.rb +13 -13
- data/test/integration/integration_test.rb +21 -17
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b7b24810e0c8880d8ad864f5300722d79486e460ed6c1d2d9ad0156d65b3057e
|
4
|
+
data.tar.gz: 3aa965eecb3bb172bb352c2638ed5be9dee440a61c6590e806f90837e7ca9d7f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 012e71481dabdd56e456d2f1620715ab681083ff0329ff0d7a647b8f6adc22601ed14f45c9776685447b49b39400e350f10701f8bc4f49018d20ba3a01f54c8b
|
7
|
+
data.tar.gz: f4e428be5627a989ffd99935e92788884f41aee0ccc015114e12b0f14a11a1a2f0f274a37ff56535f0d8d760739bff7164043ef5bdfd02dcf93757ae1a5d8d3d
|
data/Changelog.md
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
# encoding: UTF-8
|
2
1
|
# This file is auto-generated from the current state of the database. Instead
|
3
2
|
# of editing this file, please use the migrations feature of Active Record to
|
4
3
|
# incrementally modify your database, and then regenerate this schema definition.
|
@@ -11,10 +10,10 @@
|
|
11
10
|
#
|
12
11
|
# It's strongly recommended that you check this file into your version control system.
|
13
12
|
|
14
|
-
ActiveRecord::Schema.define(version:
|
13
|
+
ActiveRecord::Schema.define(version: 2014_08_30_065127) do
|
15
14
|
|
16
15
|
create_table "foos", force: :cascade do |t|
|
17
|
-
t.string
|
16
|
+
t.string "name"
|
18
17
|
t.datetime "created_at", null: false
|
19
18
|
t.datetime "updated_at", null: false
|
20
19
|
end
|
data/lib/memory_test_fix.rb
CHANGED
@@ -56,11 +56,11 @@ module MemoryTestFix
|
|
56
56
|
end
|
57
57
|
|
58
58
|
def silent?
|
59
|
-
verbosity ==
|
59
|
+
verbosity == 'silent'
|
60
60
|
end
|
61
61
|
|
62
62
|
def quiet?
|
63
|
-
verbosity ==
|
63
|
+
verbosity == 'quiet'
|
64
64
|
end
|
65
65
|
|
66
66
|
def migrate
|
@@ -68,7 +68,7 @@ module MemoryTestFix
|
|
68
68
|
end
|
69
69
|
|
70
70
|
def inform_using_in_memory
|
71
|
-
puts
|
71
|
+
puts 'Creating sqlite :memory: database'
|
72
72
|
end
|
73
73
|
|
74
74
|
def load_schema
|
data/memory_test_fix.gemspec
CHANGED
@@ -1,38 +1,38 @@
|
|
1
1
|
Gem::Specification.new do |spec|
|
2
|
-
spec.name =
|
3
|
-
spec.version =
|
2
|
+
spec.name = 'memory_test_fix'
|
3
|
+
spec.version = '1.5.1'
|
4
4
|
|
5
|
-
spec.authors = [
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
spec.email =
|
13
|
-
spec.homepage =
|
5
|
+
spec.authors = ['Matijs van Zuijlen',
|
6
|
+
'Chris Roos',
|
7
|
+
'Geoffrey Grosenbach',
|
8
|
+
'Kakutani Shintaro',
|
9
|
+
'Erik Hanson and Matt Scilipoti',
|
10
|
+
'Greg Weber',
|
11
|
+
'Stephan Zalewski']
|
12
|
+
spec.email = 'matijs@matijs.net'
|
13
|
+
spec.homepage = 'http://wiki.github.com/mvz/memory_test_fix'
|
14
14
|
|
15
|
-
spec.license =
|
15
|
+
spec.license = 'MIT'
|
16
16
|
|
17
|
-
spec.summary =
|
17
|
+
spec.summary = 'Use SQLite3 in-memory database for Rails tests.'
|
18
18
|
spec.description = <<-TEXT
|
19
19
|
Makes use of SQLite3 in-memory database possible for your
|
20
20
|
Rails tests by preloading the schema.
|
21
21
|
TEXT
|
22
22
|
spec.required_ruby_version = '>= 2.2.0'
|
23
23
|
|
24
|
-
spec.files = Dir[
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
24
|
+
spec.files = Dir['{lib,test,spec,fixtures}/**/*',
|
25
|
+
'*.md',
|
26
|
+
'*.gemspec',
|
27
|
+
'Rakefile',
|
28
|
+
'Gemfile'] & `git ls-files -z`.split("\0")
|
29
29
|
|
30
|
-
spec.rdoc_options = [
|
31
|
-
spec.extra_rdoc_files = [
|
30
|
+
spec.rdoc_options = ['--main', 'README.md']
|
31
|
+
spec.extra_rdoc_files = ['README.md']
|
32
32
|
|
33
|
-
spec.add_runtime_dependency(
|
34
|
-
spec.add_runtime_dependency(
|
35
|
-
spec.add_development_dependency(
|
36
|
-
spec.add_development_dependency(
|
37
|
-
spec.add_development_dependency(
|
33
|
+
spec.add_runtime_dependency('activerecord', '~> 5.0')
|
34
|
+
spec.add_runtime_dependency('railties', '~> 5.0')
|
35
|
+
spec.add_development_dependency('minitest', '~> 5.2')
|
36
|
+
spec.add_development_dependency('rake', '~> 12.0')
|
37
|
+
spec.add_development_dependency('rspec', '~> 3.1')
|
38
38
|
end
|
@@ -29,11 +29,11 @@ RSpec.describe MemoryTestFix::SchemaLoader do
|
|
29
29
|
context 'when no in-memory database is configured' do
|
30
30
|
let(:config) { { database: 'some/file.sqlite3', adapter: 'sqlite3' } }
|
31
31
|
|
32
|
-
it
|
32
|
+
it 'outputs nothing' do
|
33
33
|
expect { schema_loader.init_schema }.not_to output.to_stdout
|
34
34
|
end
|
35
35
|
|
36
|
-
it
|
36
|
+
it 'does not load anything' do
|
37
37
|
schema_loader.init_schema
|
38
38
|
expect(loader).not_to have_received :load_schema
|
39
39
|
end
|
@@ -42,26 +42,26 @@ RSpec.describe MemoryTestFix::SchemaLoader do
|
|
42
42
|
context 'when configured not to use migrations' do
|
43
43
|
let(:config) { base_config }
|
44
44
|
|
45
|
-
it
|
45
|
+
it 'informs the user it is creating an in-memory database' do
|
46
46
|
expect { schema_loader.init_schema }.
|
47
47
|
to output(/Creating sqlite :memory: database/).to_stdout
|
48
48
|
end
|
49
49
|
|
50
|
-
it
|
50
|
+
it 'prints the output from the loader' do
|
51
51
|
expect { schema_loader.init_schema }.
|
52
52
|
to output(/loading schema/).to_stdout
|
53
53
|
end
|
54
54
|
|
55
|
-
it
|
55
|
+
it 'tells the loader to load the schema' do
|
56
56
|
silently { schema_loader.init_schema }
|
57
57
|
expect(loader).to have_received :load_schema
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
61
|
-
context
|
61
|
+
context 'when configured to use migrations' do
|
62
62
|
let(:config) { base_config.merge(migrate: true) }
|
63
63
|
|
64
|
-
it
|
64
|
+
it 'informs the user it is creating an in-memory database' do
|
65
65
|
expect { schema_loader.init_schema }.
|
66
66
|
to output(/Creating sqlite :memory: database/).to_stdout
|
67
67
|
end
|
@@ -71,30 +71,30 @@ RSpec.describe MemoryTestFix::SchemaLoader do
|
|
71
71
|
not_to output(/loading schema/).to_stdout
|
72
72
|
end
|
73
73
|
|
74
|
-
it
|
74
|
+
it 'tells the migrator to run the migrations' do
|
75
75
|
silently { schema_loader.init_schema }
|
76
76
|
expect(migrator).to have_received :up
|
77
77
|
end
|
78
78
|
end
|
79
79
|
|
80
|
-
context
|
80
|
+
context 'when running in quietly' do
|
81
81
|
let(:config) { base_config.merge(verbosity: 'quiet') }
|
82
82
|
|
83
|
-
it
|
83
|
+
it 'informs the user it is creating an in-memory database' do
|
84
84
|
expect { schema_loader.init_schema }.
|
85
85
|
to output(/Creating sqlite :memory: database/).to_stdout
|
86
86
|
end
|
87
87
|
|
88
|
-
it
|
88
|
+
it 'does not print the output from the loader' do
|
89
89
|
expect { schema_loader.init_schema }.
|
90
90
|
not_to output(/loading schema/).to_stdout
|
91
91
|
end
|
92
92
|
end
|
93
93
|
|
94
|
-
context
|
94
|
+
context 'when running in silence' do
|
95
95
|
let(:config) { base_config.merge(verbosity: 'silent') }
|
96
96
|
|
97
|
-
it
|
97
|
+
it 'outputs nothing' do
|
98
98
|
expect { schema_loader.init_schema }.not_to output.to_stdout
|
99
99
|
end
|
100
100
|
end
|
@@ -18,7 +18,7 @@ def run_tests(command_array = %w(bundle exec rake))
|
|
18
18
|
result = in_clean_bundler_environment(*command_array)
|
19
19
|
end
|
20
20
|
# If the command failed, make it print any error messages
|
21
|
-
err.must_equal
|
21
|
+
err.must_equal '' unless result
|
22
22
|
out
|
23
23
|
end
|
24
24
|
|
@@ -29,20 +29,20 @@ def stop_spring
|
|
29
29
|
end
|
30
30
|
|
31
31
|
BASE_CONFIG = {
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
32
|
+
'development' => {
|
33
|
+
'adapter' => 'sqlite3',
|
34
|
+
'pool' => 5,
|
35
|
+
'timeout' => 5000,
|
36
|
+
'database' => 'db/development.sqlite3'
|
37
37
|
},
|
38
|
-
|
39
|
-
|
40
|
-
|
38
|
+
'test' => {
|
39
|
+
'adapter' => 'sqlite3',
|
40
|
+
'database' => ':memory:'
|
41
41
|
}
|
42
42
|
}.freeze
|
43
43
|
|
44
44
|
MIGRATING_CONFIG = BASE_CONFIG.dup.tap do |config|
|
45
|
-
config[
|
45
|
+
config['test'] = config['test'].merge('migrate' => true)
|
46
46
|
end
|
47
47
|
|
48
48
|
def create_db_config_without_migrations
|
@@ -58,9 +58,9 @@ def create_db_config_with_migrations
|
|
58
58
|
end
|
59
59
|
|
60
60
|
VERSIONS = [
|
61
|
-
[
|
62
|
-
[
|
63
|
-
[
|
61
|
+
['Rails 5.0', 'rails50_app'],
|
62
|
+
['Rails 5.1', 'rails51_app'],
|
63
|
+
['Rails 5.2', 'rails52_app']
|
64
64
|
].freeze
|
65
65
|
|
66
66
|
VERSIONS.each do |label, appdir|
|
@@ -69,43 +69,47 @@ VERSIONS.each do |label, appdir|
|
|
69
69
|
end
|
70
70
|
|
71
71
|
describe "A #{label} app using memory_test_fix" do
|
72
|
-
it
|
72
|
+
it 'can run its tests in-memory without migrations' do
|
73
73
|
Dir.chdir "fixtures/#{appdir}" do
|
74
74
|
create_db_config_without_migrations
|
75
75
|
out = run_tests
|
76
76
|
out.must_match(/Creating sqlite :memory: database/)
|
77
77
|
out.wont_match(/migrating/)
|
78
|
+
out.must_match(/2 runs, 2 assertions, 0 failures, 0 errors, 0 skips/)
|
78
79
|
end
|
79
80
|
end
|
80
81
|
|
81
|
-
it
|
82
|
+
it 'can run its tests in-memory with migrations' do
|
82
83
|
Dir.chdir "fixtures/#{appdir}" do
|
83
84
|
create_db_config_with_migrations
|
84
85
|
out = run_tests
|
85
86
|
out.must_match(/Creating sqlite :memory: database/)
|
86
87
|
out.must_match(/migrating/)
|
88
|
+
out.must_match(/2 runs, 2 assertions, 0 failures, 0 errors, 0 skips/)
|
87
89
|
end
|
88
90
|
end
|
89
91
|
|
90
92
|
describe 'when using spring' do
|
91
93
|
let(:command_array) { %w(bin/rake) }
|
92
|
-
it
|
94
|
+
it 'can run its tests in-memory without migrations' do
|
93
95
|
Dir.chdir "fixtures/#{appdir}" do
|
94
96
|
stop_spring
|
95
97
|
create_db_config_without_migrations
|
96
98
|
out = run_tests command_array
|
97
99
|
out.must_match(/Creating sqlite :memory: database/)
|
98
100
|
out.wont_match(/migrating/)
|
101
|
+
out.must_match(/2 runs, 2 assertions, 0 failures, 0 errors, 0 skips/)
|
99
102
|
end
|
100
103
|
end
|
101
104
|
|
102
|
-
it
|
105
|
+
it 'can run its tests in-memory with migrations' do
|
103
106
|
Dir.chdir "fixtures/#{appdir}" do
|
104
107
|
stop_spring
|
105
108
|
create_db_config_with_migrations
|
106
109
|
out = run_tests command_array
|
107
110
|
out.must_match(/Creating sqlite :memory: database/)
|
108
111
|
out.must_match(/migrating/)
|
112
|
+
out.must_match(/2 runs, 2 assertions, 0 failures, 0 errors, 0 skips/)
|
109
113
|
end
|
110
114
|
end
|
111
115
|
end
|