forking_test_runner 0.4.1 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/forking_test_runner.rb +14 -5
- data/lib/forking_test_runner/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f225f138349841629ffb3f3ed73ea90d2f014a7c
|
4
|
+
data.tar.gz: 17239acf778f70cca023d8962d415bbc5b53953d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: adb87e6d6591baff9be1f11386ae3b9281dfc56745305be229036f0dfe404f5cb3159ac2563a9dc00c1ad0dc7f68ed41476cb8cb5d389637efeef01dc7cefa6b
|
7
|
+
data.tar.gz: b47bd2d9f2ea6d706d18a1f7ac08d077ab6a95791cfe5069b5907b2b812f36bb6878bd550bea98d744c4be17a17cb9817c3df59e2beb2f9a64bed2eba7f969d7
|
data/lib/forking_test_runner.rb
CHANGED
@@ -6,6 +6,7 @@ module ForkingTestRunner
|
|
6
6
|
class << self
|
7
7
|
def cli(argv)
|
8
8
|
@rspec = delete_argv("--rspec", argv, arg: false)
|
9
|
+
@no_fixtures = delete_argv("--no-fixtures", argv, arg: false)
|
9
10
|
|
10
11
|
disable_test_autorun
|
11
12
|
load_test_env(delete_argv("--helper", argv))
|
@@ -109,7 +110,7 @@ module ForkingTestRunner
|
|
109
110
|
# This forces Rails to load all fixtures, then prevents it from
|
110
111
|
# "deleting and re-inserting all fixtures" when a new connection is used (forked).
|
111
112
|
def preload_fixtures
|
112
|
-
return if @preloaded
|
113
|
+
return if @preloaded || @no_fixtures
|
113
114
|
@preloaded = true
|
114
115
|
|
115
116
|
fixtures = (ActiveSupport::VERSION::MAJOR == 3 ? ActiveRecord::Fixtures : ActiveRecord::FixtureSet)
|
@@ -139,12 +140,16 @@ module ForkingTestRunner
|
|
139
140
|
end
|
140
141
|
|
141
142
|
def run_test(file)
|
142
|
-
|
143
|
-
|
143
|
+
if ar?
|
144
|
+
preload_fixtures
|
145
|
+
ActiveRecord::Base.connection.disconnect!
|
146
|
+
end
|
144
147
|
change_program_name_to file do
|
145
148
|
child = fork do
|
146
|
-
|
147
|
-
|
149
|
+
if ar?
|
150
|
+
key = (ActiveRecord::VERSION::STRING >= "4.1.0" ? :test : "test")
|
151
|
+
ActiveRecord::Base.establish_connection key
|
152
|
+
end
|
148
153
|
enable_test_autorun(file)
|
149
154
|
end
|
150
155
|
Process.wait(child)
|
@@ -187,6 +192,10 @@ module ForkingTestRunner
|
|
187
192
|
end
|
188
193
|
end
|
189
194
|
|
195
|
+
def ar?
|
196
|
+
defined?(ActiveRecord::Base)
|
197
|
+
end
|
198
|
+
|
190
199
|
def toggle_test_autorun(value, file=nil)
|
191
200
|
if @rspec
|
192
201
|
if value
|