microtest 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,152 @@
1
+ # encoding: utf-8
2
+
3
+ require 'yaml'
4
+
5
+ Gem::Specification.new do |gemspec|
6
+
7
+ manifest = Dir.glob('manifest{,.txt)', File::FNM_CASEFOLD).first
8
+
9
+ scm = case
10
+ when File.directory?('.git')
11
+ :git
12
+ end
13
+
14
+ files = case
15
+ when manifest
16
+ File.readlines(manifest).
17
+ map{ |line| line.srtip }.
18
+ reject{ |line| line.empty? || line[0,1] == '#' }
19
+ when scm == :git
20
+ `git ls-files -z`.split("\0")
21
+ else
22
+ Dir.glob('{**/}{.*,*}') # TODO: be more specific using standard locations ?
23
+ end.select{ |path| File.file?(path) }
24
+
25
+ patterns = {
26
+ :bin_files => 'bin/*',
27
+ :lib_files => 'lib/{**/}*.rb',
28
+ :ext_files => 'ext/{**/}extconf.rb',
29
+ :doc_files => '*.{txt,rdoc,md,markdown,tt,textile}',
30
+ :test_files => '{test/{**/}*_test.rb,spec/{**/}*_spec.rb}'
31
+ }
32
+
33
+ glob_files = lambda { |pattern|
34
+ Dir.glob(pattern).select { |path|
35
+ File.file?(path) && files.include?(path)
36
+ }
37
+ }
38
+
39
+ #files = glob_files[patterns[:files]]
40
+
41
+ executables = glob_files[patterns[:bin_files]].map do |path|
42
+ File.basename(path)
43
+ end
44
+
45
+ extensions = glob_files[patterns[:ext_files]].map do |path|
46
+ File.basename(path)
47
+ end
48
+
49
+ metadata = YAML.load_file('.ruby')
50
+
51
+ # build-out the gemspec
52
+
53
+ case metadata['revision']
54
+ when 0
55
+ gemspec.name = metadata['name']
56
+ gemspec.version = metadata['version']
57
+ gemspec.summary = metadata['summary']
58
+ gemspec.description = metadata['description']
59
+
60
+ metadata['authors'].each do |author|
61
+ gemspec.authors << author['name']
62
+
63
+ if author.has_key?('email')
64
+ if gemspec.email
65
+ gemspec.email << author['email']
66
+ else
67
+ gemspec.email = [author['email']]
68
+ end
69
+ end
70
+ end
71
+
72
+ gemspec.licenses = metadata['licenses']
73
+
74
+ metadata['requirements'].each do |req|
75
+ name = req['name']
76
+ version = req['version']
77
+ groups = req['groups'] || []
78
+
79
+ if md = /^(.*?)([+-~])$/.match(version)
80
+ version = case md[2]
81
+ when '+' then ">= #{$1}"
82
+ when '-' then "< #{$1}"
83
+ when '~' then "~> #{$1}"
84
+ else version
85
+ end
86
+ end
87
+
88
+ #development = req['development']
89
+ #if development
90
+ # # populate development dependencies
91
+ # if gemspec.respond_to?(:add_development_dependency)
92
+ # gemspec.add_development_dependency(name,*version)
93
+ # else
94
+ # gemspec.add_dependency(name,*version)
95
+ # end
96
+ #else
97
+ # # populate runtime dependencies
98
+ # if gemspec.respond_to?(:add_runtime_dependency)
99
+ # gemspec.add_runtime_dependency(name,*version)
100
+ # else
101
+ # gemspec.add_dependency(name,*version)
102
+ # end
103
+ #end
104
+
105
+ if groups.empty? or groups.include?('runtime')
106
+ # populate runtime dependencies
107
+ if gemspec.respond_to?(:add_runtime_dependency)
108
+ gemspec.add_runtime_dependency(name,*version)
109
+ else
110
+ gemspec.add_dependency(name,*version)
111
+ end
112
+ else
113
+ # populate development dependencies
114
+ if gemspec.respond_to?(:add_development_dependency)
115
+ gemspec.add_development_dependency(name,*version)
116
+ else
117
+ gemspec.add_dependency(name,*version)
118
+ end
119
+ end
120
+ end
121
+
122
+ # convert external dependencies into a requirements
123
+ if metadata['external_dependencies']
124
+ ##gemspec.requirements = [] unless metadata['external_dependencies'].empty?
125
+ metadata['external_dependencies'].each do |req|
126
+ gemspec.requirements << req.to_s
127
+ end
128
+ end
129
+
130
+ # determine homepage from resources
131
+ homepage = metadata['resources'].find{ |key, url| key =~ /^home/ }
132
+ gemspec.homepage = homepage.last if homepage
133
+
134
+ gemspec.require_paths = metadata['load_path'] || ['lib']
135
+ gemspec.post_install_message = metadata['install_message']
136
+
137
+ # RubyGems specific metadata
138
+ gemspec.files = files
139
+ gemspec.extensions = extensions
140
+ gemspec.executables = executables
141
+
142
+ if Gem::VERSION < '1.7.'
143
+ gemspec.default_executable = gemspec.executables.first
144
+ end
145
+
146
+ gemspec.test_files = glob_files[patterns[:test_files]]
147
+
148
+ unless gemspec.files.include?('.document')
149
+ gemspec.extra_rdoc_files = glob_files[patterns[:doc_files]]
150
+ end
151
+ end
152
+ end
data/.ruby ADDED
@@ -0,0 +1,46 @@
1
+ ---
2
+ authors:
3
+ - name: Thomas Sawyer
4
+ email: transfire@gmail.com
5
+ copyrights:
6
+ - holder: Thomas Sawyer
7
+ year: '2011'
8
+ license: BSD-2-Clause
9
+ replacements: []
10
+ conflicts: []
11
+ requirements:
12
+ - name: test
13
+ - name: detroit
14
+ groups:
15
+ - build
16
+ development: true
17
+ - name: reap
18
+ groups:
19
+ - build
20
+ development: true
21
+ - name: qed
22
+ groups:
23
+ - test
24
+ development: true
25
+ dependencies: []
26
+ repositories:
27
+ - uri: git://github.com/proutils/microtest.git
28
+ scm: git
29
+ name: upstream
30
+ resources:
31
+ home: http://rubyworks.github.com/microtest
32
+ code: http://github.com/rubyworks/microtest
33
+ load_path:
34
+ - lib
35
+ extra:
36
+ manifest: MANIFEST
37
+ alternatives: []
38
+ revision: 0
39
+ name: microtest
40
+ title: MicroTest
41
+ summary: Microminal TestUnit-style Test Framework
42
+ description: MicroTest is very small Test::Unit/MiniTest compatbile test framework
43
+ that run on top of the Ruby Universal Test Harness (Ruby Test).
44
+ organization: RubyWorks
45
+ version: 0.1.0
46
+ date: '2011-08-11'
@@ -0,0 +1,46 @@
1
+ ---
2
+ github:
3
+ active: true
4
+
5
+ gem:
6
+ active: true
7
+
8
+ dnote:
9
+ labels: ~
10
+ output: log/NOTES.rdoc
11
+
12
+ yard:
13
+ yardopts: true
14
+
15
+ qed:
16
+ files : ~
17
+ #exclude : ~
18
+ #loadpath: ~
19
+ #requires: ~
20
+ #live : false
21
+ active : false
22
+
23
+ qedoc:
24
+ files : spec/
25
+ output: QED.rdoc
26
+ active: false
27
+
28
+ vclog:
29
+ output: log/ChangeLog.rdoc
30
+ active: false
31
+
32
+ email:
33
+ service: Email
34
+ file : ~
35
+ subject: ~
36
+ mailto :
37
+ - ruby-talk@ruby-lang.org
38
+ - rubyworks-mailinglist@googlegroups.com
39
+ from : <%= ENV['EMAIL_ACCOUNT'] %>
40
+ server : <%= ENV['EMAIL_SERVER'] %>
41
+ port : <%= ENV['EMAIL_PORT'] %>
42
+ account: <%= ENV['EMAIL_ACCOUNT'] %>
43
+ domain : <%= ENV['EMAIL_DOMAIN'] %>
44
+ login : <%= ENV['EMAIL_LOGIN'] %>
45
+ secure : <%= ENV['EMAIL_SECURE'] %>
46
+
@@ -0,0 +1,31 @@
1
+ = COPYRIGHT NOTICES
2
+
3
+ == MicroTest
4
+
5
+ Copyright:: (c) 2011 Thomas Sawyer, RubyWorks
6
+ License:: BSD-2-Clause
7
+ Website:: http://rubyworks.github.com/microtest
8
+
9
+ Copyright 2011 Thomas Sawyer. All rights reserved.
10
+
11
+ Redistribution and use in source and binary forms, with or without
12
+ modification, are permitted provided that the following conditions are met:
13
+
14
+ 1. Redistributions of source code must retain the above copyright notice,
15
+ this list of conditions and the following disclaimer.
16
+
17
+ 2. Redistributions in binary form must reproduce the above copyright
18
+ notice, this list of conditions and the following disclaimer in the
19
+ documentation and/or other materials provided with the distribution.
20
+
21
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
22
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
23
+ FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24
+ COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25
+ INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26
+ NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
28
+ OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30
+ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
+
@@ -0,0 +1,9 @@
1
+ # Release History
2
+
3
+ ## 0.1.0 / 2011-08-11
4
+
5
+ This first release covers basic compatability with Test::Unit and MiniTest.
6
+
7
+ Changes:
8
+
9
+ * Happy Birthday.
@@ -0,0 +1,9 @@
1
+ #!mast .ruby .yaropts bin lib spec test [A-Z][A-Z]*
2
+ .ruby
3
+ lib/microtest/assertions.rb
4
+ lib/microtest/unit.rb
5
+ lib/microtest.rb
6
+ PROFILE
7
+ HISTORY.md
8
+ README.md
9
+ COPYING.rdoc
data/PROFILE ADDED
@@ -0,0 +1,30 @@
1
+ ---
2
+ name : microtest
3
+ title : MicroTest
4
+ summary: Microminal TestUnit-style Test Framework
5
+ authors:
6
+ - Thomas Sawyer <transfire@gmail.com>
7
+
8
+ description:
9
+ MicroTest is very small Test::Unit/MiniTest compatbile
10
+ test framework that run on top of the Ruby Universal
11
+ Test Harness (Ruby Test).
12
+
13
+ resources:
14
+ home: http://rubyworks.github.com/microtest
15
+ code: http://github.com/rubyworks/microtest
16
+
17
+ repositories:
18
+ upstream: git://github.com/proutils/microtest.git
19
+
20
+ requirements:
21
+ - test
22
+ - detroit (build)
23
+ - reap (build)
24
+ - qed (test)
25
+
26
+ organization: RubyWorks
27
+
28
+ copyrights:
29
+ - 2011 Thomas Sawyer (BSD-2-Clause)
30
+
@@ -0,0 +1,49 @@
1
+ # MicroTest
2
+
3
+ ## Description
4
+
5
+ MicroTest is a minimal Test::Unit and MiniTest campatible
6
+ test framework that runs on top of Ruby Test.
7
+
8
+ ## Synopsis
9
+
10
+ MicroTests are written in essentially the same manner as Ruby standard
11
+ test frameworks.
12
+
13
+ ```ruby
14
+ require 'microtest/assertions' # for legacy assertion methods
15
+
16
+ class ExampleTest < MicroTest::TestCase
17
+
18
+ #
19
+ def setup
20
+ @a = 1
21
+ end
22
+
23
+ #
24
+ def test_alpha_is_one
25
+ assert_equal(1, @a)
26
+ end
27
+
28
+ end
29
+ ```
30
+
31
+ For drop in compatability with Test::Unit, load `microtest/test/unit`.
32
+
33
+ ```ruby
34
+ require 'microtest/unit'
35
+
36
+ class ExampleTest < Test::Unit::TestCase
37
+ ...
38
+ end
39
+ ```
40
+
41
+ # Copyrights and Licensing
42
+
43
+ Copyright (c) 2011 Thomas Sawyer, Rubyworks
44
+
45
+ MicroTest is distributes under the terms of the **FreeBSD** license.
46
+
47
+ See COPYING.rdoc for more information.
48
+
49
+
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,77 @@
1
+ module MicroTest
2
+
3
+ #
4
+ def self.natural_names
5
+ @natural_names ||= nil
6
+ end
7
+
8
+ #
9
+ def self.natural_names=(boolean)
10
+ @natural_names = !!boolean
11
+ end
12
+
13
+ # The World serves as a base class in which the end-tester can
14
+ # add univerally available test helpers for all test cases.
15
+ class World
16
+ end
17
+
18
+ #
19
+ class TestCase < World
20
+
21
+ def self.inherited(subclass)
22
+ subclass.new
23
+ end
24
+
25
+ #
26
+ def self.new(*a,&b)
27
+ $TEST_SUITE << super(*a,&b)
28
+ end
29
+
30
+ #
31
+ def to_s
32
+ self.class.name
33
+ end
34
+
35
+ #
36
+ def call(&cont)
37
+ setup
38
+ cont.call
39
+ teardown
40
+ end
41
+
42
+ #
43
+ def each
44
+ methods.each do |m|
45
+ next unless m.to_s.start_with?('test_')
46
+ yield(TestMethod.new(method(m)))
47
+ end
48
+ end
49
+
50
+ #
51
+ def setup
52
+ end
53
+
54
+ #
55
+ def teardown
56
+ end
57
+
58
+ end
59
+
60
+ #
61
+ class TestMethod
62
+ def initialize(method)
63
+ @method = method
64
+ end
65
+
66
+ def call
67
+ @method.call
68
+ end
69
+
70
+ def to_s
71
+ name = @method.name.to_s
72
+ name.gsub!('_', ' ') if MicroTest.natural_names
73
+ return name
74
+ end
75
+ end
76
+
77
+ end
@@ -0,0 +1,350 @@
1
+ module MicroTest
2
+
3
+ # Legacy Assertions
4
+ #
5
+ # This module provides a compatibility layer for Test::Unit/MiniTest.
6
+ # This is an optional module and must be loaded on it's own.
7
+ #
8
+ # Note that two methods are not provided, +#assert_nothing_raised+,
9
+ # and +#assert_nothing_thrown+.
10
+ #
11
+ module Assertions
12
+
13
+ # Private method upon which all of the legacy assertions are based
14
+ # (except for #assert itself).
15
+ #
16
+ # @raise [Assertion] If test fails.
17
+ #
18
+ # @return nothing
19
+ def __assert__(test, msg=nil)
20
+ msg = "failed assertion (no message given)" unless msg
21
+ raise Assertion.new(msg, :backtrace=>caller[1..-1]) unless test
22
+ end
23
+
24
+ private :__assert__
25
+
26
+ # The assertion upon which all other assertions are based.
27
+ #
28
+ # @example
29
+ # assert [1, 2].include?(5)
30
+ #
31
+ # @return [Assertor] if `test` not given
32
+ def assert(test, msg=nil)
33
+ msg = "failed assertion (no message given)" unless msg
34
+ raise Assertion.new(msg, :backtrace=>caller) unless test
35
+ end
36
+
37
+ # Passes if the block yields true.
38
+ #
39
+ # @example
40
+ # assert_block "Couldn't do the thing" do
41
+ # do_the_thing
42
+ # end
43
+ #
44
+ # @raise [Assertion] if test fails
45
+ #
46
+ # @return nothing
47
+ def assert_block(msg=nil) # :yields:
48
+ test = ! yield
49
+ msg = "assertion failed" unless msg
50
+ __assert__(test, msg)
51
+ end
52
+
53
+ # Passes if expected == +actual.
54
+ #
55
+ # Note that the ordering of arguments is important,
56
+ # since a helpful error message is generated when this
57
+ # one fails that tells you the values of expected and actual.
58
+ #
59
+ # @example
60
+ # assert_equal 'MY STRING', 'my string'.upcase
61
+ #
62
+ # @raise [Assertion] if test fails
63
+ #
64
+ # @return nothing
65
+ def assert_equal(exp, act, msg=nil)
66
+ test = (exp == act)
67
+ msg = "Expected #{act.inspect} to be equal to #{exp.inspect}" unless msg
68
+ __assert__(test, msg)
69
+ end
70
+
71
+ # Passes if expected_float and actual_float are equal within delta tolerance.
72
+ #
73
+ # @example
74
+ # assert_in_delta 0.05, (50000.0 / 10**6), 0.00001
75
+ #
76
+ # @raise [Assertion] if test fails
77
+ #
78
+ # @return nothing
79
+ def assert_in_delta(exp, act, delta, msg=nil)
80
+ test = (exp.to_f - act.to_f).abs <= delta.to_f
81
+ msg = "Expected #{exp} to be within #{delta} of #{act}" unless msg
82
+ __assert__(test, msg)
83
+ end
84
+
85
+ # Passes if object .instance_of? klass
86
+ #
87
+ # @example
88
+ # assert_instance_of String, 'foo'
89
+ #
90
+ # @raise [Assertion] if test fails
91
+ #
92
+ # @return nothing
93
+ def assert_instance_of(cls, obj, msg=nil)
94
+ test = (cls === obj)
95
+ msg = "Expected #{obj} to be a #{cls}" unless msg
96
+ __assert__(test, msg)
97
+ end
98
+
99
+ # Passes if object .kind_of? klass
100
+ #
101
+ # @example
102
+ # assert_kind_of Object, 'foo'
103
+ #
104
+ # @raise [Assertion] if test fails
105
+ #
106
+ # @return nothing
107
+ def assert_kind_of(cls, obj, msg=nil)
108
+ test = obj.kind_of?(cls)
109
+ msg = "Expected #{obj.inspect} to be a kind of #{cls}" unless msg
110
+ __assert__(test, msg)
111
+ end
112
+
113
+ # Passes if string =~ pattern.
114
+ #
115
+ # @example
116
+ # assert_match(/\d+/, 'five, 6, seven')
117
+ #
118
+ # @raise [Assertion] if test fails
119
+ #
120
+ # @return nothing
121
+ def assert_match(exp, act, msg=nil)
122
+ test = (act =~ exp)
123
+ msg = "Expected #{act.inspect} to match #{exp.inspect}" unless msg
124
+ __assert__(test, msg)
125
+ end
126
+
127
+ # Passes if object is nil.
128
+ #
129
+ # @example
130
+ # assert_nil [1, 2].uniq!
131
+ #
132
+ # @raise [Assertion] if test fails
133
+ #
134
+ # @return nothing
135
+ def assert_nil(obj, msg=nil)
136
+ test = obj.nil?
137
+ msg = "Expected #{obj.inspect} to be nil" unless msg
138
+ __assert__(test, msg)
139
+ end
140
+
141
+ # Passes if regexp !~ string
142
+ #
143
+ # @example
144
+ # assert_no_match(/two/, 'one 2 three')
145
+ #
146
+ # @raise [Assertion] if test fails
147
+ #
148
+ # @return nothing
149
+ def assert_no_match(exp, act, msg=nil)
150
+ test = (act !~ exp)
151
+ msg = "Expected #{act.inspect} to match #{exp.inspect}" unless msg
152
+ __assert__(test, msg)
153
+ end
154
+
155
+ # Passes if expected != actual
156
+ #
157
+ # @example
158
+ # assert_not_equal 'some string', 5
159
+ #
160
+ # @raise [Assertion] if test fails
161
+ #
162
+ # @return nothing
163
+ def assert_not_equal(exp, act, msg=nil)
164
+ test = (exp != act)
165
+ msg = "Expected #{act.inspect} to not be equal to #{exp.inspect}" unless msg
166
+ __assert__(test, msg)
167
+ end
168
+
169
+ # Passes if ! object .nil?
170
+ #
171
+ # @example
172
+ # assert_not_nil '1 two 3'.sub!(/two/, '2')
173
+ #
174
+ # @raise [Assertion] if test fails
175
+ #
176
+ # @return nothing
177
+ def assert_not_nil(obj, msg=nil)
178
+ test = ! obj.nil?
179
+ msg = "Expected #{obj.inspect} to not be nil" unless msg
180
+ __assert__(test, msg)
181
+ end
182
+
183
+ # Passes if ! actual .equal? expected
184
+ #
185
+ # @example
186
+ # assert_not_same Object.new, Object.new
187
+ #
188
+ # @raise [Assertion] if test fails
189
+ #
190
+ # @return nothing
191
+ def assert_not_same(exp, act, msg=nil)
192
+ test = ! exp.equal?(act)
193
+ msg = "Expected #{act.inspect} to not be the same as #{exp.inspect}" unless msg
194
+ __assert__(test, msg)
195
+ end
196
+
197
+ # Compares the +object1+ with +object2+ using operator.
198
+ #
199
+ # Passes if object1.send(operator, object2) is true.
200
+ #
201
+ # @example
202
+ # assert_operator 5, :>=, 4
203
+ #
204
+ # @raise [Assertion] if test fails
205
+ #
206
+ # @return nothing
207
+ def assert_operator(o1, op, o2, msg="")
208
+ test = o1.__send__(op, o2)
209
+ msg = "Expected #{o1}.#{op}(#{o2}) to be true" unless msg
210
+ __assert__(test, msg)
211
+ end
212
+
213
+ # Passes if the block raises one of the given exceptions.
214
+ #
215
+ # @example
216
+ # assert_raise RuntimeError, LoadError do
217
+ # raise 'Boom!!!'
218
+ # end
219
+ #
220
+ # @raise [Assertion] if test fails
221
+ #
222
+ # @return nothing
223
+ def assert_raises(*args)
224
+ msg = (Module === args.last ? nil : args.pop)
225
+ begin
226
+ yield
227
+ msg = "Expected #{exp} to be raised" unless msg
228
+ __assert__(false, msg)
229
+ rescue Exception => e
230
+ test = (exp === e)
231
+ msg = "Expected #{exp} to be raised, but got #{e.class}" unless msg
232
+ __assert__(test, msg)
233
+ return e
234
+ end
235
+ end
236
+
237
+ alias_method :assert_raise, :assert_raises
238
+
239
+ # Provides a way to assert that a procedure
240
+ # <i>does not</i> raise an exception.
241
+ #
242
+ # @example
243
+ # refute_raises(StandardError){ raise }
244
+ #
245
+ #def assert_raises!(exception, &block)
246
+ # begin
247
+ # block.call(*a)
248
+ # rescue exception
249
+ # raise Assertion
250
+ # end
251
+ #end
252
+ #alias_method :refute_raises, :assert_raises!
253
+
254
+ # Passes if +object+ respond_to? +method+.
255
+ #
256
+ # @example
257
+ # assert_respond_to 'bugbear', :slice
258
+ #
259
+ # @raise [Assertion] if test fails
260
+ #
261
+ # @return nothing
262
+ def assert_respond_to(obj, meth, msg=nil)
263
+ msg = "Expected #{obj} (#{obj.class}) to respond to ##{meth}" unless msg
264
+ #flip = (Symbol === obj) && ! (Symbol === meth) # HACK for specs
265
+ #obj, meth = meth, obj if flip
266
+ test = obj.respond_to?(meth)
267
+ __assert__(test, msg)
268
+ end
269
+
270
+ # Passes if +actual+ .equal? +expected+ (i.e. they are the same instance).
271
+ #
272
+ # @example
273
+ # o = Object.new
274
+ # assert_same(o, o)
275
+ #
276
+ # @raise [Assertion] if test fails
277
+ #
278
+ # @return nothing
279
+ def assert_same(exp, act, msg=nil)
280
+ msg = "Expected #{act.inspect} to be the same as #{exp.inspect}" unless msg
281
+ test = exp.equal?(act)
282
+ __assert__(test, msg)
283
+ end
284
+
285
+ # Passes if the method send returns a true value.
286
+ # The parameter +send_array+ is composed of:
287
+ #
288
+ # * A receiver
289
+ # * A method
290
+ # * Arguments to the method
291
+ #
292
+ # @example
293
+ # assert_send [[1, 2], :include?, 4]
294
+ #
295
+ # @raise [Assertion] if test fails
296
+ #
297
+ # @return nothing
298
+ def assert_send(send_array, msg=nil)
299
+ r, m, *args = *send_array
300
+ test = r.__send__(m, *args)
301
+ msg = "Expected #{r}.#{m}(*#{args.inspect}) to return true" unless msg
302
+ __assert__(test, msg)
303
+ end
304
+
305
+ # Passes if the block throws expected_symbol
306
+ #
307
+ # @example
308
+ # assert_throws :done do
309
+ # throw :done
310
+ # end
311
+ #
312
+ # @raise [Assertion] if test fails
313
+ #
314
+ # @return nothing
315
+ def assert_throws(sym, msg=nil)
316
+ msg = "Expected #{sym} to have been thrown" unless msg
317
+ test = true
318
+ catch(sym) do
319
+ begin
320
+ yield
321
+ rescue ArgumentError => e # 1.9 exception
322
+ default += ", not #{e.message.split(/ /).last}"
323
+ rescue NameError => e # 1.8 exception
324
+ default += ", not #{e.name.inspect}"
325
+ end
326
+ test = false
327
+ end
328
+ __assert__(test, msg)
329
+ end
330
+
331
+ # Flunk always fails.
332
+ #
333
+ # @example
334
+ # flunk 'Not done testing yet.'
335
+ #
336
+ # @raise [Assertion] always
337
+ #
338
+ # @return nothing
339
+ def flunk(msg=nil)
340
+ __assert__(false, msg)
341
+ end
342
+
343
+ end
344
+
345
+ #
346
+ class World
347
+ include Assertions
348
+ end
349
+
350
+ end
@@ -0,0 +1,8 @@
1
+ require 'microtest'
2
+
3
+ module Test
4
+ module Unit
5
+ TestCase = MicroTest::TestCase
6
+ end
7
+ end
8
+
@@ -0,0 +1,2 @@
1
+ $:.unshift(File.dirname(__FILE__)+'/../lib')
2
+
@@ -0,0 +1,14 @@
1
+ require 'microtest'
2
+ require 'microtest/assertions'
3
+
4
+ class ExampleTest < MicroTest::TestCase
5
+
6
+ def setup
7
+ @a = 1
8
+ end
9
+
10
+ def test_example_of_passing_test
11
+ assert_equal(1, @a)
12
+ end
13
+
14
+ end
@@ -0,0 +1,15 @@
1
+ require 'microtest/unit'
2
+ require 'microtest/assertions'
3
+
4
+ class ExampleTest < Test::Unit::TestCase
5
+
6
+ def setup
7
+ @a = 1
8
+ end
9
+
10
+ def test_example_of_passing_test
11
+ assert_equal(1, @a)
12
+ end
13
+
14
+ end
15
+
metadata ADDED
@@ -0,0 +1,108 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: microtest
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Thomas Sawyer
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-08-11 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: test
16
+ requirement: &12648320 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *12648320
25
+ - !ruby/object:Gem::Dependency
26
+ name: detroit
27
+ requirement: &12646440 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *12646440
36
+ - !ruby/object:Gem::Dependency
37
+ name: reap
38
+ requirement: &15175400 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *15175400
47
+ - !ruby/object:Gem::Dependency
48
+ name: qed
49
+ requirement: &15174900 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: *15174900
58
+ description: MicroTest is very small Test::Unit/MiniTest compatbile test framework
59
+ that run on top of the Ruby Universal Test Harness (Ruby Test).
60
+ email:
61
+ - transfire@gmail.com
62
+ executables: []
63
+ extensions: []
64
+ extra_rdoc_files:
65
+ - COPYING.rdoc
66
+ - HISTORY.md
67
+ - README.md
68
+ files:
69
+ - .gemspec
70
+ - .ruby
71
+ - Assembly
72
+ - COPYING.rdoc
73
+ - HISTORY.md
74
+ - MANIFEST
75
+ - PROFILE
76
+ - README.md
77
+ - VERSION
78
+ - lib/microtest.rb
79
+ - lib/microtest/assertions.rb
80
+ - lib/microtest/unit.rb
81
+ - try/.test
82
+ - try/test_example.rb
83
+ - try/test_unit_example.rb
84
+ homepage: http://rubyworks.github.com/microtest
85
+ licenses: []
86
+ post_install_message:
87
+ rdoc_options: []
88
+ require_paths:
89
+ - lib
90
+ required_ruby_version: !ruby/object:Gem::Requirement
91
+ none: false
92
+ requirements:
93
+ - - ! '>='
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ required_rubygems_version: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ requirements: []
103
+ rubyforge_project:
104
+ rubygems_version: 1.8.5
105
+ signing_key:
106
+ specification_version: 3
107
+ summary: Microminal TestUnit-style Test Framework
108
+ test_files: []