cwninja-drunit 0.3.1 → 0.4.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/Rakefile +1 -1
- data/lib/drunit.rb +18 -1
- data/lib/drunit/remote_app.rb +2 -2
- data/lib/drunit/remote_test.rb +12 -6
- data/test/fake_app/fake_app.rb +6 -0
- data/test/unit/main_test.rb +7 -0
- data/test/unit/test_case_switching_test.rb +17 -0
- metadata +4 -2
data/Rakefile
CHANGED
@@ -17,7 +17,7 @@ end
|
|
17
17
|
|
18
18
|
spec = Gem::Specification.new do |s|
|
19
19
|
s.name = %q{drunit}
|
20
|
-
s.version = "0.
|
20
|
+
s.version = "0.4.0"
|
21
21
|
s.summary = %q{A library for running tests across multiple applications from a single test case.}
|
22
22
|
s.description = %q{A library for running tests across multiple applications from a single test case.}
|
23
23
|
|
data/lib/drunit.rb
CHANGED
@@ -6,6 +6,15 @@ module Drunit
|
|
6
6
|
def RemoteApp(name, *args)
|
7
7
|
const_set "RemoteAppFor_#{name}", RemoteApp.new(name, *args)
|
8
8
|
end
|
9
|
+
|
10
|
+
def drunit_test_case_class_name
|
11
|
+
@drunit_test_case_class_name ||
|
12
|
+
(superclass.respond_to?(:drunit_test_case_class_name) ? superclass.drunit_test_case_class_name : "Test::Unit::TestCase")
|
13
|
+
end
|
14
|
+
|
15
|
+
def set_drunit_test_case_class_name(name)
|
16
|
+
@drunit_test_case_class_name = name
|
17
|
+
end
|
9
18
|
end
|
10
19
|
|
11
20
|
def in_app(name, *args, &block)
|
@@ -42,7 +51,15 @@ private
|
|
42
51
|
|
43
52
|
def remote_test_case_for(name)
|
44
53
|
@remote_test_cases ||= {}
|
45
|
-
@remote_test_cases[name.to_sym] ||= remote_app_for(name).new_test_case
|
54
|
+
@remote_test_cases[name.to_sym] ||= remote_app_for(name).new_test_case(drunit_test_case_class_name)
|
55
|
+
end
|
56
|
+
|
57
|
+
def set_drunit_test_case_class_name(name)
|
58
|
+
@drunit_test_case_class_name = name
|
59
|
+
end
|
60
|
+
|
61
|
+
def drunit_test_case_class_name
|
62
|
+
@drunit_test_case_class_name || self.class.drunit_test_case_class_name
|
46
63
|
end
|
47
64
|
|
48
65
|
def caller_file_and_method_for_block(&block)
|
data/lib/drunit/remote_app.rb
CHANGED
data/lib/drunit/remote_test.rb
CHANGED
@@ -4,14 +4,19 @@ require File.join(File.dirname(__FILE__), *%w[remote_error])
|
|
4
4
|
|
5
5
|
module Drunit
|
6
6
|
class RemoteTest
|
7
|
-
def new_test_case
|
8
|
-
|
7
|
+
def new_test_case(name)
|
8
|
+
tc = Class.new(eval(name, Object.class_eval{ binding }))
|
9
|
+
tc.send(:include, TestCaseModule)
|
10
|
+
tc.allocate
|
9
11
|
end
|
10
12
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
13
|
+
module TestCaseModule
|
14
|
+
def self.included(other)
|
15
|
+
other.send(:class_eval) do
|
16
|
+
include DRb::DRbUndumped
|
17
|
+
attr_reader :assertion_count
|
18
|
+
end
|
19
|
+
end
|
15
20
|
|
16
21
|
def initialize
|
17
22
|
@assertion_count = 0
|
@@ -26,6 +31,7 @@ module Drunit
|
|
26
31
|
end
|
27
32
|
|
28
33
|
def run(method_name, *args)
|
34
|
+
@assertion_count = 0
|
29
35
|
rewrite_exceptions{ __send__(method_name, *args) }
|
30
36
|
end
|
31
37
|
|
data/test/fake_app/fake_app.rb
CHANGED
data/test/unit/main_test.rb
CHANGED
@@ -35,6 +35,13 @@ class MainTest < Test::Unit::TestCase
|
|
35
35
|
assert_equal original_count + 1, @_result.assertion_count
|
36
36
|
end
|
37
37
|
|
38
|
+
def test_should_not_count_the_same_assert_twice
|
39
|
+
original_count = @_result.assertion_count
|
40
|
+
InApp{ assert true}
|
41
|
+
InApp{ assert true}
|
42
|
+
assert_equal original_count + 2, @_result.assertion_count
|
43
|
+
end
|
44
|
+
|
38
45
|
def test_should_be_able_to_pass_in_simple_params
|
39
46
|
assert_equal 12, InApp(2,6){|a,b| SomeFoo.new.multiply(a, b)}
|
40
47
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), *%w[.. test_helper])
|
2
|
+
|
3
|
+
class SomeOtherTestCaseTest < Test::Unit::TestCase
|
4
|
+
include Drunit
|
5
|
+
RemoteApp(:fake_app, FAKE_APP_PATH + "/fake_app.rb")
|
6
|
+
def InApp(*args, &block)
|
7
|
+
in_app(:fake_app, *args, &block)
|
8
|
+
end
|
9
|
+
|
10
|
+
set_drunit_test_case_class_name "SomeOtherTestCase"
|
11
|
+
|
12
|
+
def test_foo
|
13
|
+
InApp{ assert_in_new_test_case }
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cwninja-drunit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tom Lea
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-06-08 00:00:00 -07:00
|
13
13
|
default_executable: drunit_remote
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -32,6 +32,7 @@ files:
|
|
32
32
|
- test/test_helper.rb
|
33
33
|
- test/unit/exception_handling_test.rb
|
34
34
|
- test/unit/main_test.rb
|
35
|
+
- test/unit/test_case_switching_test.rb
|
35
36
|
- bin/drunit_remote
|
36
37
|
has_rdoc: true
|
37
38
|
homepage:
|
@@ -65,3 +66,4 @@ summary: A library for running tests across multiple applications from a single
|
|
65
66
|
test_files:
|
66
67
|
- test/unit/exception_handling_test.rb
|
67
68
|
- test/unit/main_test.rb
|
69
|
+
- test/unit/test_case_switching_test.rb
|