miniunit 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
metadata CHANGED
@@ -1,66 +1,82 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.9.4
3
- specification_version: 1
4
2
  name: miniunit
5
3
  version: !ruby/object:Gem::Version
6
- version: 1.1.0
7
- date: 2007-11-08 00:00:00 -08:00
8
- summary: miniunit is a completely minimial drop-in replacement for ruby's test/unit.
9
- require_paths:
10
- - lib
11
- email: ryand-ruby@zenspider.com
12
- homepage: " http://rubyforge.org/projects/bfts"
13
- rubyforge_project: bfts
14
- description: miniunit is a completely minimial drop-in replacement for ruby's test/unit. This is meant to be clean and easy to use both as a regular test writer and for language implementors that need a minimal set of methods to bootstrap a working unit test suite.
15
- autorequire:
16
- default_executable:
17
- bindir: bin
18
- has_rdoc: true
19
- required_ruby_version: !ruby/object:Gem::Version::Requirement
20
- requirements:
21
- - - ">"
22
- - !ruby/object:Gem::Version
23
- version: 0.0.0
24
- version:
4
+ version: 1.2.0
25
5
  platform: ruby
26
- signing_key:
27
- cert_chain:
28
- post_install_message:
29
6
  authors:
30
7
  - Ryan Davis
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-06-09 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: hoe
17
+ version_requirement:
18
+ version_requirements: !ruby/object:Gem::Requirement
19
+ requirements:
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 1.5.3
23
+ version:
24
+ description: mini/test is a completely minimial drop-in replacement for ruby's test/unit. This is meant to be clean and easy to use both as a regular test writer and for language implementors that need a minimal set of methods to bootstrap a working unit test suite. mini/spec is a functionally complete spec engine. mini/mock, by Steven Baker, is a beautifully tiny mock object framework.
25
+ email:
26
+ - ryand-ruby@zenspider.com
27
+ executables:
28
+ - use_miniunit
29
+ extensions: []
30
+
31
+ extra_rdoc_files:
32
+ - History.txt
33
+ - Manifest.txt
34
+ - README.txt
31
35
  files:
32
36
  - .autotest
33
37
  - History.txt
34
38
  - Manifest.txt
35
39
  - README.txt
36
40
  - Rakefile
41
+ - bin/use_miniunit
42
+ - lib/mini/mock.rb
43
+ - lib/mini/spec.rb
44
+ - lib/mini/test.rb
37
45
  - lib/test/unit.rb
46
+ - lib/test/unit/assertions.rb
47
+ - lib/test/unit/error.rb
38
48
  - lib/test/unit/testcase.rb
39
- - test/test_test_case.rb
40
- - test/test_test_unit.rb
41
- test_files:
42
- - test/test_test_case.rb
43
- - test/test_test_unit.rb
49
+ - test/test_mini_mock.rb
50
+ - test/test_mini_spec.rb
51
+ - test/test_mini_test.rb
52
+ has_rdoc: true
53
+ homepage: http://rubyforge.org/projects/bfts
54
+ post_install_message:
44
55
  rdoc_options:
45
56
  - --main
46
57
  - README.txt
47
- extra_rdoc_files:
48
- - History.txt
49
- - Manifest.txt
50
- - README.txt
51
- executables: []
52
-
53
- extensions: []
54
-
58
+ require_paths:
59
+ - lib
60
+ required_ruby_version: !ruby/object:Gem::Requirement
61
+ requirements:
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ version: "0"
65
+ version:
66
+ required_rubygems_version: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: "0"
71
+ version:
55
72
  requirements: []
56
73
 
57
- dependencies:
58
- - !ruby/object:Gem::Dependency
59
- name: hoe
60
- version_requirement:
61
- version_requirements: !ruby/object:Gem::Version::Requirement
62
- requirements:
63
- - - ">="
64
- - !ruby/object:Gem::Version
65
- version: 1.3.0
66
- version:
74
+ rubyforge_project: bfts
75
+ rubygems_version: 1.1.1
76
+ signing_key:
77
+ specification_version: 2
78
+ summary: mini/test is a completely minimial drop-in replacement for ruby's test/unit
79
+ test_files:
80
+ - test/test_mini_mock.rb
81
+ - test/test_mini_spec.rb
82
+ - test/test_mini_test.rb
@@ -1,321 +0,0 @@
1
- #!/usr/local/bin/ruby -w
2
-
3
- $TESTING_TEST_UNIT = true
4
-
5
- require 'test/unit'
6
-
7
- # TODO: add message versions
8
- class TestTestCase < MiniTest::Unit::TestCase
9
- def setup
10
- util_test_suites.clear
11
- @tc = MiniTest::Unit::TestCase.new
12
- @zomg = "zomg ponies!"
13
- @assertion_count = 1
14
- end
15
-
16
- def teardown
17
- assert_equal @assertion_count, @tc._assertions if @tc._assertions
18
- Object.send :remove_const, :ATestCase if defined? ATestCase
19
- end
20
-
21
- def test_class_inherited
22
- util_test_case
23
- assert util_test_suites[ATestCase]
24
- end
25
-
26
- def test_class_test_suites
27
- util_test_case
28
- assert_equal 1, MiniTest::Unit::TestCase.test_suites.size
29
- assert_equal [ATestCase], MiniTest::Unit::TestCase.test_suites
30
- end
31
-
32
- def test_assert
33
- @tc.assert true
34
- @tc.assert true, "message"
35
- @assertion_count = 2
36
- end
37
-
38
- def test_assert_triggered
39
- util_assert_triggered "failed assertion (no message given)" do
40
- @tc.assert false
41
- end
42
- end
43
-
44
- def test_assert_triggered_message
45
- util_assert_triggered @zomg do
46
- @tc.assert false, @zomg
47
- end
48
- end
49
-
50
- def test_assert_block
51
- @tc.assert_block do
52
- true
53
- end
54
- end
55
-
56
- def test_assert_block_triggered
57
- util_assert_triggered 'assert_block failed.' do
58
- @tc.assert_block do
59
- false
60
- end
61
- end
62
- end
63
-
64
- def test_assert_equal
65
- @tc.assert_equal 1, 1
66
- end
67
-
68
- def test_assert_equal_triggered
69
- util_assert_triggered "<1> expected but was\n<2>." do
70
- @tc.assert_equal 1, 2
71
- end
72
- end
73
-
74
- def test_assert_in_delta
75
- @tc.assert_in_delta 0.0, 1.0 / 1000, 0.1
76
- end
77
-
78
- def test_assert_in_delta_triggered
79
- util_assert_triggered 'Expected 0.0 to be within 1.0e-06 of 0.001' do
80
- @tc.assert_in_delta 0.0, 1.0 / 1000, 0.000001
81
- end
82
- end
83
-
84
- def test_assert_instance_of
85
- @tc.assert_instance_of String, "blah"
86
- end
87
-
88
- def test_assert_instance_of_triggered
89
- util_assert_triggered 'Expected "blah" to be an instance of Array' do
90
- @tc.assert_instance_of Array, "blah"
91
- end
92
- end
93
-
94
- def test_assert_kind_of
95
- @tc.assert_kind_of String, "blah"
96
- end
97
-
98
- def test_assert_kind_of_triggered
99
- util_assert_triggered 'Expected "blah" to be a kind of Array' do
100
- @tc.assert_kind_of Array, "blah"
101
- end
102
- end
103
-
104
- def test_assert_match
105
- @tc.assert_match "blah blah blah", /\w+/
106
- end
107
-
108
- def test_assert_match_triggered
109
- util_assert_triggered 'Expected /\d+/ to match "blah blah blah"' do
110
- @tc.assert_match "blah blah blah", /\d+/
111
- end
112
- end
113
-
114
- def test_assert_nil
115
- @tc.assert_nil nil
116
- end
117
-
118
- def test_assert_nil_triggered
119
- util_assert_triggered 'Expected 42 to be nil' do
120
- @tc.assert_nil 42
121
- end
122
- end
123
-
124
- def test_assert_no_match
125
- @tc.assert_no_match "blah blah blah", /\d+/
126
- end
127
-
128
- def test_assert_no_match_triggered
129
- util_assert_triggered 'Expected /\w+/ to not match "blah blah blah"' do
130
- @tc.assert_no_match "blah blah blah", /\w+/
131
- end
132
- end
133
-
134
- def test_assert_not_equal
135
- @tc.assert_not_equal "blah", "yay"
136
- end
137
-
138
- def test_assert_not_equal_triggered
139
- util_assert_triggered 'Expected "blah" to not be equal to "blah"' do
140
- @tc.assert_not_equal "blah", "blah"
141
- end
142
- end
143
-
144
- def test_assert_not_nil
145
- @tc.assert_not_nil 42
146
- end
147
-
148
- def test_assert_not_nil_triggered
149
- util_assert_triggered 'Expected nil to not be nil' do
150
- @tc.assert_not_nil nil
151
- end
152
- end
153
-
154
- def test_assert_not_same
155
- @tc.assert_not_same 1, 2
156
- end
157
-
158
- # TODO: "with id <id>" crap from assertions.rb
159
- def test_assert_not_same_triggered
160
- util_assert_triggered 'Expected 1 to not be the same as 1' do
161
- @tc.assert_not_same 1, 1
162
- end
163
- end
164
-
165
- def test_assert_nothing_raised
166
- @tc.assert_nothing_raised do
167
- # do nothing
168
- end
169
- end
170
-
171
- def test_assert_nothing_raised_triggered
172
- expected = 'Exception raised:
173
- Class: <RuntimeError>
174
- Message: <"oops!">
175
- ---Backtrace---'
176
-
177
- util_assert_triggered expected do
178
- @tc.assert_nothing_raised do
179
- raise "oops!"
180
- end
181
- end
182
- end
183
-
184
- def test_assert_operator
185
- @tc.assert_operator 2, :>, 1
186
- end
187
-
188
- def test_assert_operator_triggered
189
- util_assert_triggered "<2> expected to be\n:<\n<1>." do
190
- @tc.assert_operator 2, :<, 1
191
- end
192
- end
193
-
194
- def test_assert_raises
195
- @tc.assert_raises RuntimeError do
196
- raise "blah"
197
- end
198
- end
199
-
200
- def test_assert_raises_triggered_none
201
- e = @tc.assert_raises MiniTest::Assertion do
202
- # do nothing
203
- end
204
-
205
- expected = "<MiniTest::Assertion> exception expected but none was thrown."
206
-
207
- assert_equal expected, e.message
208
- # @assertion_count = 2
209
- end
210
-
211
- def test_assert_raises_triggered_wrong
212
- e = assert_raises(MiniTest::Assertion) do
213
- @tc.assert_raises RuntimeError do
214
- raise SyntaxError, "icky"
215
- end
216
- end
217
-
218
- expected = "<RuntimeError> exception expected but was
219
- Class: <SyntaxError>
220
- Message: <\"icky\">
221
- ---Backtrace---"
222
-
223
- assert_equal expected, e.message.sub(/(---Backtrace---).*/m, '\1')
224
- end
225
-
226
- def test_assert_respond_to
227
- @tc.assert_respond_to "blah", :empty?
228
- end
229
-
230
- def test_assert_respond_to_triggered
231
- util_assert_triggered 'Expected "blah" of type String to respond_to? :rawr!' do
232
- @tc.assert_respond_to "blah", :rawr!
233
- end
234
- end
235
-
236
- def test_assert_same
237
- o = "blah"
238
- @tc.assert_same 1, 1
239
- @tc.assert_same :blah, :blah
240
- @tc.assert_same o, o
241
- @assertion_count = 3
242
- end
243
-
244
- def test_assert_same_triggered
245
- util_assert_triggered 'Expected 2 to be the same as 1.' do
246
- @tc.assert_same 1, 2
247
- end
248
-
249
- util_assert_triggered 'Expected "blah" to be the same as "blah".' do
250
- s1 = "blah"
251
- s2 = "blah"
252
- @tc.assert_same s1, s2
253
- end
254
-
255
- @assertion_count = 2
256
- end
257
-
258
- def test_assert_send
259
- o = [ 42 ]
260
- @tc.assert_send([o, :clear])
261
- assert_equal [], o
262
- end
263
-
264
- def test_assert_send_triggered
265
- util_assert_triggered '<"blah"> expected to respond to
266
- <:empty?> with a true value.' do
267
- o = "blah"
268
- @tc.assert_send([o, :empty?])
269
- end
270
- end
271
-
272
- def test_assert_throws
273
- @tc.assert_throws(:blah) do
274
- throw :blah
275
- end
276
- end
277
-
278
- def test_assert_throws_triggered
279
- util_assert_triggered '<:blah> should have been thrown.' do
280
- @tc.assert_throws(:blah) do
281
- # do nothing
282
- end
283
- end
284
- end
285
-
286
- def test_assert_throws_triggered_different
287
- util_assert_triggered '<:blah> should have been thrown.' do
288
- @tc.assert_throws(:blah) do
289
- throw :not_blah
290
- end
291
- end
292
- end
293
-
294
- def test_flunk
295
- util_assert_triggered 'Flunked' do
296
- @tc.flunk
297
- end
298
- end
299
-
300
- def test_flunk_message
301
- util_assert_triggered @zomg do
302
- @tc.flunk @zomg
303
- end
304
- end
305
-
306
- def util_assert_triggered expected
307
- e = assert_raises(MiniTest::Assertion) do
308
- yield
309
- end
310
-
311
- assert_equal expected, e.message.sub(/(---Backtrace---).*/m, '\1')
312
- end
313
-
314
- def util_test_suites
315
- MiniTest::Unit::TestCase.__send__(:class_variable_get, :@@test_suites)
316
- end
317
-
318
- def util_test_case
319
- Object.const_set(:ATestCase, Class.new(MiniTest::Unit::TestCase))
320
- end
321
- end
@@ -1,75 +0,0 @@
1
- #!/usr/local/bin/ruby -w
2
-
3
- require 'stringio'
4
-
5
- $TESTING_MINIUNIT = true
6
-
7
- require 'test/unit'
8
-
9
- class TestTestUnit < MiniTest::Unit::TestCase
10
-
11
- def setup
12
- MiniTest::Unit::TestCase.reset
13
- @tu = MiniTest::Unit.new
14
- MiniTest::Unit.output = StringIO.new("")
15
- assert_equal [0, 0], @tu.run_test_suites
16
- end
17
-
18
- def teardown
19
- MiniTest::Unit.output = $stdout
20
- end
21
-
22
- def test_class_puke_with_assertion_failed
23
- exception = MiniTest::Assertion.new "Oh no!"
24
- exception.set_backtrace ["unhappy"]
25
- assert_equal 'F', @tu.puke('SomeClass', 'method_name', exception)
26
- assert_equal 1, @tu.failures
27
- assert_match(/^Failure.*Oh no!/m, @tu.report.first)
28
- end
29
-
30
- def test_class_puke_with_failure_and_flunk_in_backtrace
31
- exception = begin
32
- MiniTest::Unit::TestCase.new.flunk
33
- rescue MiniTest::Assertion => failure
34
- failure
35
- end
36
- assert_equal 'F', @tu.puke('SomeClass', 'method_name', exception)
37
- assert !@tu.report.any?{|line| line =~ /in .flunk/}
38
- end
39
-
40
- def test_class_puke_with_non_failure_exception
41
- exception = Exception.new("Oh no again!")
42
- assert_equal 'E', @tu.puke('SomeClass', 'method_name', exception)
43
- assert_equal 1, @tu.errors
44
- assert_match(/^Exception.*Oh no again!/m, @tu.report.first)
45
- end
46
-
47
- def test_class_run_test_suites
48
- create_a_test_case_named("ATestCase")
49
- assert_equal [1, 1], @tu.run_test_suites
50
- end
51
-
52
- def test_class_autotest_failing
53
- create_a_test_case_named("FailingTest", :failing => true)
54
- @tu.autotest
55
- assert_equal(1, @tu.report.size)
56
- assert_match(/test_failure/, @tu.report.first)
57
- end
58
-
59
- def test_class_autotest_passing
60
- create_a_test_case_named("PassingTest")
61
- @tu.autotest
62
- assert_equal([], @tu.report)
63
- end
64
-
65
- def create_a_test_case_named(name, options = {})
66
- eval <<-CODE
67
- class #{name} < MiniTest::Unit::TestCase
68
- def test_something
69
- assert true
70
- end
71
- #{if options[:failing]; "def test_failure; assert false; end"; end}
72
- end
73
- CODE
74
- end
75
- end