test_unit_helper 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +3 -0
- data/README +82 -0
- data/lib/test_unit_helper.rb +37 -0
- data/lib/test_unit_helper/class_methods.rb +66 -0
- data/lib/test_unit_helper/ext/test/unit/test_case.rb +40 -0
- data/lib/test_unit_helper/instance_methods.rb +102 -0
- data/license/gplv3 +612 -0
- data/license/lgplv3 +157 -0
- data/license/lgplv3.png +0 -0
- data/rakefile +1 -0
- data/test/helper.rb +3 -0
- data/test/lib/dumb.rb +2 -0
- data/test/unit/dumb_test.rb +20 -0
- data/test/unit/output_test.rb +94 -0
- data/test/unit/test_dumb.rb +21 -0
- data/test/unit/test_test_case.rb +22 -0
- data/test_unit_helper.gemspec +25 -0
- metadata +82 -0
data/license/lgplv3
ADDED
@@ -0,0 +1,157 @@
|
|
1
|
+
This version of the GNU Lesser General Public License incorporates
|
2
|
+
the terms and conditions of version 3 of the GNU General Public
|
3
|
+
License, supplemented by the additional permissions listed below.
|
4
|
+
|
5
|
+
0. Additional Definitions.
|
6
|
+
|
7
|
+
As used herein, "this License" refers to version 3 of the GNU Lesser
|
8
|
+
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
9
|
+
General Public License.
|
10
|
+
|
11
|
+
"The Library" refers to a covered work governed by this License,
|
12
|
+
other than an Application or a Combined Work as defined below.
|
13
|
+
|
14
|
+
An "Application" is any work that makes use of an interface provided
|
15
|
+
by the Library, but which is not otherwise based on the Library.
|
16
|
+
Defining a subclass of a class defined by the Library is deemed a mode
|
17
|
+
of using an interface provided by the Library.
|
18
|
+
|
19
|
+
A "Combined Work" is a work produced by combining or linking an
|
20
|
+
Application with the Library. The particular version of the Library
|
21
|
+
with which the Combined Work was made is also called the "Linked
|
22
|
+
Version".
|
23
|
+
|
24
|
+
The "Minimal Corresponding Source" for a Combined Work means the
|
25
|
+
Corresponding Source for the Combined Work, excluding any source code
|
26
|
+
for portions of the Combined Work that, considered in isolation, are
|
27
|
+
based on the Application, and not on the Linked Version.
|
28
|
+
|
29
|
+
The "Corresponding Application Code" for a Combined Work means the
|
30
|
+
object code and/or source code for the Application, including any data
|
31
|
+
and utility programs needed for reproducing the Combined Work from the
|
32
|
+
Application, but excluding the System Libraries of the Combined Work.
|
33
|
+
|
34
|
+
1. Exception to Section 3 of the GNU GPL.
|
35
|
+
|
36
|
+
You may convey a covered work under sections 3 and 4 of this License
|
37
|
+
without being bound by section 3 of the GNU GPL.
|
38
|
+
|
39
|
+
2. Conveying Modified Versions.
|
40
|
+
|
41
|
+
If you modify a copy of the Library, and, in your modifications, a
|
42
|
+
facility refers to a function or data to be supplied by an Application
|
43
|
+
that uses the facility (other than as an argument passed when the
|
44
|
+
facility is invoked), then you may convey a copy of the modified
|
45
|
+
version:
|
46
|
+
|
47
|
+
a) under this License, provided that you make a good faith effort to
|
48
|
+
ensure that, in the event an Application does not supply the
|
49
|
+
function or data, the facility still operates, and performs
|
50
|
+
whatever part of its purpose remains meaningful, or
|
51
|
+
|
52
|
+
b) under the GNU GPL, with none of the additional permissions of
|
53
|
+
this License applicable to that copy.
|
54
|
+
|
55
|
+
3. Object Code Incorporating Material from Library Header Files.
|
56
|
+
|
57
|
+
The object code form of an Application may incorporate material from
|
58
|
+
a header file that is part of the Library. You may convey such object
|
59
|
+
code under terms of your choice, provided that, if the incorporated
|
60
|
+
material is not limited to numerical parameters, data structure
|
61
|
+
layouts and accessors, or small macros, inline functions and templates
|
62
|
+
(ten or fewer lines in length), you do both of the following:
|
63
|
+
|
64
|
+
a) Give prominent notice with each copy of the object code that the
|
65
|
+
Library is used in it and that the Library and its use are
|
66
|
+
covered by this License.
|
67
|
+
|
68
|
+
b) Accompany the object code with a copy of the GNU GPL and this license
|
69
|
+
document.
|
70
|
+
|
71
|
+
4. Combined Works.
|
72
|
+
|
73
|
+
You may convey a Combined Work under terms of your choice that,
|
74
|
+
taken together, effectively do not restrict modification of the
|
75
|
+
portions of the Library contained in the Combined Work and reverse
|
76
|
+
engineering for debugging such modifications, if you also do each of
|
77
|
+
the following:
|
78
|
+
|
79
|
+
a) Give prominent notice with each copy of the Combined Work that
|
80
|
+
the Library is used in it and that the Library and its use are
|
81
|
+
covered by this License.
|
82
|
+
|
83
|
+
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
84
|
+
document.
|
85
|
+
|
86
|
+
c) For a Combined Work that displays copyright notices during
|
87
|
+
execution, include the copyright notice for the Library among
|
88
|
+
these notices, as well as a reference directing the user to the
|
89
|
+
copies of the GNU GPL and this license document.
|
90
|
+
|
91
|
+
d) Do one of the following:
|
92
|
+
|
93
|
+
0) Convey the Minimal Corresponding Source under the terms of this
|
94
|
+
License, and the Corresponding Application Code in a form
|
95
|
+
suitable for, and under terms that permit, the user to
|
96
|
+
recombine or relink the Application with a modified version of
|
97
|
+
the Linked Version to produce a modified Combined Work, in the
|
98
|
+
manner specified by section 6 of the GNU GPL for conveying
|
99
|
+
Corresponding Source.
|
100
|
+
|
101
|
+
1) Use a suitable shared library mechanism for linking with the
|
102
|
+
Library. A suitable mechanism is one that (a) uses at run time
|
103
|
+
a copy of the Library already present on the user's computer
|
104
|
+
system, and (b) will operate properly with a modified version
|
105
|
+
of the Library that is interface-compatible with the Linked
|
106
|
+
Version.
|
107
|
+
|
108
|
+
e) Provide Installation Information, but only if you would otherwise
|
109
|
+
be required to provide such information under section 6 of the
|
110
|
+
GNU GPL, and only to the extent that such information is
|
111
|
+
necessary to install and execute a modified version of the
|
112
|
+
Combined Work produced by recombining or relinking the
|
113
|
+
Application with a modified version of the Linked Version. (If
|
114
|
+
you use option 4d0, the Installation Information must accompany
|
115
|
+
the Minimal Corresponding Source and Corresponding Application
|
116
|
+
Code. If you use option 4d1, you must provide the Installation
|
117
|
+
Information in the manner specified by section 6 of the GNU GPL
|
118
|
+
for conveying Corresponding Source.)
|
119
|
+
|
120
|
+
5. Combined Libraries.
|
121
|
+
|
122
|
+
You may place library facilities that are a work based on the
|
123
|
+
Library side by side in a single library together with other library
|
124
|
+
facilities that are not Applications and are not covered by this
|
125
|
+
License, and convey such a combined library under terms of your
|
126
|
+
choice, if you do both of the following:
|
127
|
+
|
128
|
+
a) Accompany the combined library with a copy of the same work based
|
129
|
+
on the Library, uncombined with any other library facilities,
|
130
|
+
conveyed under the terms of this License.
|
131
|
+
|
132
|
+
b) Give prominent notice with the combined library that part of it
|
133
|
+
is a work based on the Library, and explaining where to find the
|
134
|
+
accompanying uncombined form of the same work.
|
135
|
+
|
136
|
+
6. Revised Versions of the GNU Lesser General Public License.
|
137
|
+
|
138
|
+
The Free Software Foundation may publish revised and/or new versions
|
139
|
+
of the GNU Lesser General Public License from time to time. Such new
|
140
|
+
versions will be similar in spirit to the present version, but may
|
141
|
+
differ in detail to address new problems or concerns.
|
142
|
+
|
143
|
+
Each version is given a distinguishing version number. If the
|
144
|
+
Library as you received it specifies that a certain numbered version
|
145
|
+
of the GNU Lesser General Public License "or any later version"
|
146
|
+
applies to it, you have the option of following the terms and
|
147
|
+
conditions either of that published version or of any later version
|
148
|
+
published by the Free Software Foundation. If the Library as you
|
149
|
+
received it does not specify a version number of the GNU Lesser
|
150
|
+
General Public License, you may choose any version of the GNU Lesser
|
151
|
+
General Public License ever published by the Free Software Foundation.
|
152
|
+
|
153
|
+
If the Library as you received it specifies that a proxy can decide
|
154
|
+
whether future versions of the GNU Lesser General Public License shall
|
155
|
+
apply, that proxy's public statement of acceptance of any version is
|
156
|
+
permanent authorization for you to choose that version for the
|
157
|
+
Library.
|
data/license/lgplv3.png
ADDED
Binary file
|
data/rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'rake_tasks'
|
data/test/helper.rb
ADDED
data/test/lib/dumb.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require_relative '../helper.rb'
|
2
|
+
|
3
|
+
class DumbTest < Test::Unit::TestCase
|
4
|
+
test 'class variable should exist' do
|
5
|
+
assert defined?(@class)
|
6
|
+
assert_same Dumb, @class
|
7
|
+
end
|
8
|
+
|
9
|
+
test '#instance_method should prefix class name' do
|
10
|
+
assert_equal :'test Dumb#instance_method should prefix class name ', __method__
|
11
|
+
end
|
12
|
+
|
13
|
+
test '.class_method should prefix class name' do
|
14
|
+
assert_equal :'test Dumb.class_method should prefix class name ', __method__
|
15
|
+
end
|
16
|
+
|
17
|
+
test 'this should not prefix class name' do
|
18
|
+
assert_equal :'test this should not prefix class name ', __method__
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,94 @@
|
|
1
|
+
require_relative '../helper.rb'
|
2
|
+
|
3
|
+
class OutputTest < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
assert_equal '', out
|
6
|
+
assert_equal '', err
|
7
|
+
end
|
8
|
+
|
9
|
+
test 'wrap_output should trap standard out' do
|
10
|
+
std_out = $stdout
|
11
|
+
wrap_output {
|
12
|
+
puts 'standard out'
|
13
|
+
}
|
14
|
+
assert_equal std_out, $stdout
|
15
|
+
assert_equal "standard out\n", @out.string
|
16
|
+
end
|
17
|
+
|
18
|
+
test 'wrap_output should trap standard error' do
|
19
|
+
std_err = $stderr
|
20
|
+
wrap_output {
|
21
|
+
warn 'standard error'
|
22
|
+
}
|
23
|
+
assert_equal std_err, $stderr
|
24
|
+
assert_equal "standard error\n", @err.string
|
25
|
+
end
|
26
|
+
|
27
|
+
test 'wrap_output should reset standard out and standard error if the block raises an error' do
|
28
|
+
std_out = $stdout
|
29
|
+
std_err = $stderr
|
30
|
+
assert_raise(RuntimeError) {
|
31
|
+
wrap_output {
|
32
|
+
raise 'random error'
|
33
|
+
}
|
34
|
+
}
|
35
|
+
assert_equal std_out, $stdout
|
36
|
+
assert_equal std_err, $stderr
|
37
|
+
end
|
38
|
+
|
39
|
+
test 'out and err should remove the trailing new line' do
|
40
|
+
wrap_output {
|
41
|
+
puts 'one'
|
42
|
+
puts 'two'
|
43
|
+
warn 'one'
|
44
|
+
warn 'two'
|
45
|
+
}
|
46
|
+
assert_equal "one\ntwo", out
|
47
|
+
assert_equal "one\ntwo", err
|
48
|
+
end
|
49
|
+
|
50
|
+
test 'standard out and standard error can be tracked across calls to wrap_output until reset' do
|
51
|
+
wrap_output {
|
52
|
+
puts 'one out'
|
53
|
+
warn 'one err'
|
54
|
+
}
|
55
|
+
wrap_output {
|
56
|
+
puts 'two out'
|
57
|
+
warn 'two err'
|
58
|
+
}
|
59
|
+
assert_equal "one out\ntwo out", out
|
60
|
+
assert_equal "one err\ntwo err", err
|
61
|
+
|
62
|
+
reset_io
|
63
|
+
|
64
|
+
wrap_output {
|
65
|
+
puts 'three out'
|
66
|
+
warn 'three err'
|
67
|
+
}
|
68
|
+
assert_equal 'three out', out
|
69
|
+
assert_equal 'three err', err
|
70
|
+
end
|
71
|
+
|
72
|
+
test 'out and err strip all trailing new lines' do
|
73
|
+
wrap_output {
|
74
|
+
puts 'out'
|
75
|
+
puts ''
|
76
|
+
puts ''
|
77
|
+
warn 'err'
|
78
|
+
warn ''
|
79
|
+
warn ''
|
80
|
+
}
|
81
|
+
assert_equal 'out', out
|
82
|
+
assert_equal 'err', err
|
83
|
+
end
|
84
|
+
|
85
|
+
test 'real_finis should return both standard out and standard error' do
|
86
|
+
wrap_output {
|
87
|
+
puts 'one'
|
88
|
+
warn 'two'
|
89
|
+
}
|
90
|
+
assert_equal 'one', out
|
91
|
+
assert_equal 'two', err
|
92
|
+
assert_equal [out, err], real_finis
|
93
|
+
end
|
94
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require_relative '../helper.rb'
|
2
|
+
|
3
|
+
class TestDumb < Test::Unit::TestCase
|
4
|
+
test 'class variable should exist' do
|
5
|
+
assert defined?(@class)
|
6
|
+
assert_same Dumb, @class
|
7
|
+
end
|
8
|
+
|
9
|
+
test '#instance_method should prefix class name' do
|
10
|
+
assert_equal :'test Dumb#instance_method should prefix class name ', __method__
|
11
|
+
end
|
12
|
+
|
13
|
+
test '.class_method should prefix class name' do
|
14
|
+
assert_equal :'test Dumb.class_method should prefix class name ', __method__
|
15
|
+
end
|
16
|
+
|
17
|
+
test 'this should not prefix class name' do
|
18
|
+
assert_equal :'test this should not prefix class name ', __method__
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require_relative '../helper.rb'
|
2
|
+
|
3
|
+
class TestTestCase < Test::Unit::TestCase
|
4
|
+
def test_assert_true_should_pass
|
5
|
+
assert true
|
6
|
+
assert_equal :test_assert_true_should_pass, __method__
|
7
|
+
end
|
8
|
+
|
9
|
+
test '"assert true" should pass' do
|
10
|
+
assert true
|
11
|
+
assert_equal :'test "assert true" should pass ', __method__
|
12
|
+
end
|
13
|
+
|
14
|
+
test 'class variable should not be defined' do
|
15
|
+
assert !defined?(@class)
|
16
|
+
assert_equal :'test class variable should not be defined ', __method__
|
17
|
+
end
|
18
|
+
|
19
|
+
test '#something should not have a class added to it' do
|
20
|
+
assert_equal :'test #something should not have a class added to it ', __method__
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = 'test_unit_helper'
|
3
|
+
s.version = '0.0.1'
|
4
|
+
|
5
|
+
s.summary = 'Provides additional functionality to Test::Unit'
|
6
|
+
s.description = %Q{
|
7
|
+
TestUnitHelper provides additional functionality to Test::Unit.
|
8
|
+
}.strip
|
9
|
+
|
10
|
+
s.author = 'Travis Herrick'
|
11
|
+
s.email = 'tthetoad@gmail.com'
|
12
|
+
s.homepage = 'http://www.bitbucket.org/ToadJamb/gems_test_unit_helper'
|
13
|
+
|
14
|
+
s.license = 'LGPLV3'
|
15
|
+
|
16
|
+
s.extra_rdoc_files = ['README', 'license/gplv3', 'license/lgplv3']
|
17
|
+
|
18
|
+
s.require_paths = ['lib']
|
19
|
+
s.files = Dir['lib/**/*.rb', 'license/**/*', '*'] - Dir['Gemfile.lock']
|
20
|
+
s.test_files = Dir['test/**/*.rb']
|
21
|
+
|
22
|
+
s.add_development_dependency 'rake_tasks', '~> 2.0.5'
|
23
|
+
|
24
|
+
s.has_rdoc = true
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: test_unit_helper
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Travis Herrick
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-03-04 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rake_tasks
|
16
|
+
requirement: &14625900 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 2.0.5
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *14625900
|
25
|
+
description: TestUnitHelper provides additional functionality to Test::Unit.
|
26
|
+
email: tthetoad@gmail.com
|
27
|
+
executables: []
|
28
|
+
extensions: []
|
29
|
+
extra_rdoc_files:
|
30
|
+
- README
|
31
|
+
- license/gplv3
|
32
|
+
- license/lgplv3
|
33
|
+
files:
|
34
|
+
- lib/test_unit_helper.rb
|
35
|
+
- lib/test_unit_helper/instance_methods.rb
|
36
|
+
- lib/test_unit_helper/class_methods.rb
|
37
|
+
- lib/test_unit_helper/ext/test/unit/test_case.rb
|
38
|
+
- license/gplv3
|
39
|
+
- license/lgplv3
|
40
|
+
- license/lgplv3.png
|
41
|
+
- README
|
42
|
+
- Gemfile
|
43
|
+
- rakefile
|
44
|
+
- test_unit_helper.gemspec
|
45
|
+
- test/helper.rb
|
46
|
+
- test/unit/test_test_case.rb
|
47
|
+
- test/unit/dumb_test.rb
|
48
|
+
- test/unit/test_dumb.rb
|
49
|
+
- test/unit/output_test.rb
|
50
|
+
- test/lib/dumb.rb
|
51
|
+
homepage: http://www.bitbucket.org/ToadJamb/gems_test_unit_helper
|
52
|
+
licenses:
|
53
|
+
- LGPLV3
|
54
|
+
post_install_message:
|
55
|
+
rdoc_options: []
|
56
|
+
require_paths:
|
57
|
+
- lib
|
58
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
59
|
+
none: false
|
60
|
+
requirements:
|
61
|
+
- - ! '>='
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '0'
|
64
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
requirements: []
|
71
|
+
rubyforge_project:
|
72
|
+
rubygems_version: 1.8.10
|
73
|
+
signing_key:
|
74
|
+
specification_version: 3
|
75
|
+
summary: Provides additional functionality to Test::Unit
|
76
|
+
test_files:
|
77
|
+
- test/helper.rb
|
78
|
+
- test/unit/test_test_case.rb
|
79
|
+
- test/unit/dumb_test.rb
|
80
|
+
- test/unit/test_dumb.rb
|
81
|
+
- test/unit/output_test.rb
|
82
|
+
- test/lib/dumb.rb
|