duck_test 0.1.4 → 0.1.5
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/lib/duck_test/autorun.rb +20 -0
- data/lib/duck_test/base.rb +1 -0
- data/lib/duck_test/frame_work/base.rb +22 -2
- data/lib/duck_test/frame_work/rspec/frame_work.rb +1 -1
- data/lib/duck_test/frame_work/test_unit/frame_work.rb +1 -1
- data/lib/duck_test/logger.rb +1 -1
- data/lib/duck_test/railtie.rb +13 -4
- data/lib/duck_test/version.rb +1 -1
- metadata +3 -2
@@ -0,0 +1,20 @@
|
|
1
|
+
module DuckTest
|
2
|
+
|
3
|
+
# ...
|
4
|
+
class Autorun
|
5
|
+
|
6
|
+
##################################################################################
|
7
|
+
def self.config
|
8
|
+
::Test::Unit::Runner.class_eval do
|
9
|
+
alias_method :original_run, :run
|
10
|
+
def run(args = [])
|
11
|
+
if DuckTest::FrameWork::Base.ok_to_run
|
12
|
+
original_run(args)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
data/lib/duck_test/base.rb
CHANGED
@@ -4,6 +4,7 @@ require "duck_test/version"
|
|
4
4
|
module DuckTest
|
5
5
|
|
6
6
|
autoload :AutoloadConfig, 'duck_test/autoload_config'
|
7
|
+
autoload :Autorun, 'duck_test/autorun'
|
7
8
|
autoload :Config, 'duck_test/config'
|
8
9
|
autoload :ConfigHelper, 'duck_test/config_helper'
|
9
10
|
autoload :Console, 'duck_test/console'
|
@@ -128,6 +128,18 @@ module DuckTest
|
|
128
128
|
|
129
129
|
end
|
130
130
|
|
131
|
+
##################################################################################
|
132
|
+
# Global flag used to prevent Test::Unit::Runner from running automatically after exiting the console
|
133
|
+
# @return [Boolean]
|
134
|
+
def self.ok_to_run
|
135
|
+
@@ok_to_run = false unless defined?(@@ok_to_run)
|
136
|
+
return @@ok_to_run
|
137
|
+
end
|
138
|
+
|
139
|
+
def self.ok_to_run=(value)
|
140
|
+
@@ok_to_run = value
|
141
|
+
end
|
142
|
+
|
131
143
|
##################################################################################
|
132
144
|
# Processes a list of file specifications and prepares them to be run
|
133
145
|
def queue_event(event)
|
@@ -303,8 +315,13 @@ module DuckTest
|
|
303
315
|
|
304
316
|
self.pre_run.call self unless self.pre_run.blank?
|
305
317
|
|
318
|
+
self.class.ok_to_run = true
|
319
|
+
|
306
320
|
run_tests
|
307
321
|
|
322
|
+
# prevents tests from autorunning when the console exits.
|
323
|
+
self.class.ok_to_run = false
|
324
|
+
|
308
325
|
self.post_run.call self unless self.post_run.blank?
|
309
326
|
|
310
327
|
end
|
@@ -314,8 +331,11 @@ module DuckTest
|
|
314
331
|
Process.wait pid
|
315
332
|
|
316
333
|
end
|
317
|
-
|
318
|
-
|
334
|
+
|
335
|
+
if defined?(ActiveRecord::Base)
|
336
|
+
::ActiveRecord::Base.clear_active_connections!
|
337
|
+
::ActiveRecord::Base.establish_connection
|
338
|
+
end
|
319
339
|
|
320
340
|
end
|
321
341
|
|
data/lib/duck_test/logger.rb
CHANGED
data/lib/duck_test/railtie.rb
CHANGED
@@ -1,7 +1,5 @@
|
|
1
|
-
# TODO figure out a good strategy for setting autoload_paths or getting the test/specs into the load path to run tests in the console.
|
2
1
|
require 'active_support'
|
3
2
|
require 'irb' unless defined?(IRB)
|
4
|
-
#require 'rspec'
|
5
3
|
|
6
4
|
module DuckTest
|
7
5
|
extend ActiveSupport::Autoload
|
@@ -19,8 +17,19 @@ module DuckTest
|
|
19
17
|
DuckTest::Config.reload!
|
20
18
|
end
|
21
19
|
|
22
|
-
|
23
|
-
|
20
|
+
initializer 'duck_test' do
|
21
|
+
|
22
|
+
# $0 holds the name of the ruby file initially loaded by the ruby interpreter.
|
23
|
+
# this is basicially preventing the run method from being aliased and overridden if the gem
|
24
|
+
# is loaded as the result of running a rake task such as rake test:units
|
25
|
+
# if started using a command like: rails c test, then, the following if statement should evaluate to true
|
26
|
+
# and re-configure Test::Unit::Runner to alias the run method and check a class variable on DuckTest::FrameWork::Base.ok_to_run
|
27
|
+
# if true, the tests should run, otherwise, the tests should not run. this should prevent tests from running when
|
28
|
+
# the console exits.
|
29
|
+
if $0 =~ /rails$/
|
30
|
+
Autorun.config
|
31
|
+
end
|
32
|
+
end
|
24
33
|
|
25
34
|
IRB::ExtendCommandBundle.send :include, DuckTest::Console
|
26
35
|
|
data/lib/duck_test/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: duck_test
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-03-01 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: DuckTest is a gem that facilitates automated running of TestUnit and
|
15
15
|
RSpec tests directly in the IRB console. Tests run within a second of being changed.
|
@@ -32,6 +32,7 @@ files:
|
|
32
32
|
- lib/duck_test/option_parser.rb
|
33
33
|
- lib/duck_test/usage.rb
|
34
34
|
- lib/duck_test/commands.rb
|
35
|
+
- lib/duck_test/autorun.rb
|
35
36
|
- lib/duck_test/platforms/dependencies.rb
|
36
37
|
- lib/duck_test/platforms/watch_event.rb
|
37
38
|
- lib/duck_test/platforms/listener.rb
|