minitest 2.3.1 → 2.4.0

Sign up to get free protection for your applications and to get access to all the features.
data.tar.gz.sig CHANGED
Binary file
@@ -1,3 +1,19 @@
1
+ === 2.4.0 / 2011-08-09
2
+
3
+ * 4 minor enhancements:
4
+
5
+ * Added simple examples for all expectations.
6
+ * Improved Mock error output when args mismatch.
7
+ * Moved all expectations from Object to MiniTest::Expectations.
8
+ * infect_with_assertions has been removed due to excessive clever
9
+
10
+ * 4 bug fixes:
11
+
12
+ * Fix Assertions#mu_pp to deal with immutable encoded strings. (ferrous26)
13
+ * Fix minitest/pride for MacRuby (ferrous26)
14
+ * Made error output less fancy so it is more readable
15
+ * Mock shouldn't undef === and inspect. (dgraham)
16
+
1
17
  === 2.3.1 / 2011-06-22
2
18
 
3
19
  * 1 bug fix:
data/README.txt CHANGED
@@ -1,6 +1,7 @@
1
- = minitest/*
1
+ = minitest/{unit,spec,mock,benchmark}
2
2
 
3
- * http://rubyforge.org/projects/bfts
3
+ home :: https://github.com/seattlerb/minitest
4
+ rdoc :: http://bfts.rubyforge.org/minitest
4
5
 
5
6
  == DESCRIPTION:
6
7
 
@@ -24,7 +25,7 @@ minitest/mock by Steven Baker, is a beautifully tiny mock object
24
25
  framework.
25
26
 
26
27
  minitest/pride shows pride in testing and adds coloring to your test
27
- output.
28
+ output. I guess it is an example of how to write IO pipes too. :P
28
29
 
29
30
  minitest/unit is meant to have a clean implementation for language
30
31
  implementors that need a minimal set of methods to bootstrap a working
@@ -247,7 +248,7 @@ the gem, but you'll need to activate the gem explicitly to use it:
247
248
 
248
249
  (The MIT License)
249
250
 
250
- Copyright (c) Ryan Davis, Seattle.rb
251
+ Copyright (c) Ryan Davis, seattle.rb
251
252
 
252
253
  Permission is hereby granted, free of charge, to any person obtaining
253
254
  a copy of this software and associated documentation files (the
data/Rakefile CHANGED
@@ -18,6 +18,57 @@ def loc dir
18
18
  system "find #{dir} -name \\*.rb | xargs wc -l | tail -1"
19
19
  end
20
20
 
21
+ desc "Find missing expectations"
22
+ task :specs do
23
+ $:.unshift "lib"
24
+ require "minitest/unit"
25
+ require "minitest/spec"
26
+
27
+ pos_prefix, neg_prefix = "must", "wont"
28
+ skip_re = /^(must|wont)$|wont_(throw)|must_(block|not?_|nothing|raise$)/x
29
+ dont_flip_re = /(must|wont)_(include|respond_to)/
30
+
31
+ map = {
32
+ /(must_throw)s/ => '\1',
33
+ /(?!not)_same/ => '_be_same_as',
34
+ /_in_/ => '_be_within_',
35
+ /_operator/ => '_be',
36
+ /_includes/ => '_include',
37
+ /(must|wont)_(.*_of|nil|silent|empty)/ => '\1_be_\2',
38
+ /must_raises/ => 'must_raise',
39
+ }
40
+
41
+ expectations = MiniTest::Expectations.public_instance_methods.map(&:to_s)
42
+ assertions = MiniTest::Assertions.public_instance_methods.map(&:to_s)
43
+
44
+ assertions.sort.each do |assertion|
45
+ expectation = case assertion
46
+ when /^assert/ then
47
+ assertion.sub(/^assert/, pos_prefix.to_s)
48
+ when /^refute/ then
49
+ assertion.sub(/^refute/, neg_prefix.to_s)
50
+ end
51
+
52
+ next unless expectation
53
+ next if expectation =~ skip_re
54
+
55
+ regexp, replacement = map.find { |re, _| expectation =~ re }
56
+ expectation.sub! regexp, replacement if replacement
57
+
58
+ next if expectations.include? expectation
59
+
60
+ args = [assertion, expectation].map(&:to_sym).map(&:inspect)
61
+ args << :reverse if expectation =~ dont_flip_re
62
+
63
+ puts
64
+ puts "##"
65
+ puts "# :method: #{expectation}"
66
+ puts "# See MiniTest::Assertions##{assertion}"
67
+ puts
68
+ puts "infect_an_assertion #{args.join ", "}"
69
+ end
70
+ end
71
+
21
72
  desc "stupid line count"
22
73
  task :dickwag do
23
74
  puts
@@ -11,8 +11,10 @@ module MiniTest
11
11
  class Mock
12
12
  alias :__respond_to? :respond_to?
13
13
 
14
- instance_methods.each do |m|
15
- undef_method m unless m =~ /^__|object_id|respond_to_missing?/
14
+ skip_methods = %w(object_id respond_to_missing? inspect === to_s)
15
+
16
+ instance_methods.each do |m|
17
+ undef_method m unless skip_methods.include?(m.to_s) || m =~ /^__/
16
18
  end
17
19
 
18
20
  def initialize # :nodoc:
@@ -54,28 +56,39 @@ module MiniTest
54
56
  def verify
55
57
  @expected_calls.each_key do |name|
56
58
  expected = @expected_calls[name]
57
- msg = "expected #{name}, #{expected.inspect}"
58
- raise MockExpectationError, msg unless
59
+ msg1 = "expected #{name}, #{expected.inspect}"
60
+ msg2 = "#{msg1}, got #{@actual_calls[name].inspect}"
61
+
62
+ raise MockExpectationError, msg2 if
63
+ @actual_calls.has_key? name and
64
+ not @actual_calls[name].include?(expected)
65
+
66
+ raise MockExpectationError, msg1 unless
59
67
  @actual_calls.has_key? name and @actual_calls[name].include?(expected)
60
68
  end
61
69
  true
62
70
  end
63
71
 
64
72
  def method_missing(sym, *args) # :nodoc:
65
- unless @expected_calls.has_key?(sym)
66
- raise NoMethodError, "unmocked method '%s', expected one of %s" %
67
- [sym, @expected_calls.keys.map{|s| "'#{s}'" }.sort.join(", ")]
73
+ expected = @expected_calls[sym]
74
+
75
+ unless expected then
76
+ raise NoMethodError, "unmocked method %p, expected one of %p" %
77
+ [sym, @expected_calls.keys.sort_by(&:to_s)]
68
78
  end
69
79
 
70
- unless @expected_calls[sym][:args].size == args.size
71
- raise ArgumentError, "mocked method '%s' expects %d arguments, got %d" %
72
- [sym, @expected_calls[sym][:args].size, args.size]
80
+ expected_args, retval = expected[:args], expected[:retval]
81
+
82
+ unless expected_args.size == args.size
83
+ raise ArgumentError, "mocked method %p expects %d arguments, got %d" %
84
+ [sym, expected[:args].size, args.size]
73
85
  end
74
86
 
75
- retval = @expected_calls[sym][:retval]
76
- args_case = @expected_calls[sym][:args].
77
- each_with_index.map{|a, i| a if a === args[i]}
78
- @actual_calls[sym] << { :retval => retval, :args => args_case }
87
+ @actual_calls[sym] << {
88
+ :retval => retval,
89
+ :args => expected_args.zip(args).map { |mod, a| mod if mod === a }
90
+ }
91
+
79
92
  retval
80
93
  end
81
94
 
@@ -6,20 +6,19 @@ require "minitest/unit"
6
6
  class PrideIO
7
7
  attr_reader :io
8
8
 
9
- # stolen from /System/Library/Perl/5.10.0/Term/ANSIColor.pm
10
- COLORS = (31..36).to_a
11
- CHARS = ["*"]
12
-
13
9
  def initialize io
14
10
  @io = io
15
- @colors = COLORS.cycle
16
- @chars = CHARS.cycle
11
+ # stolen from /System/Library/Perl/5.10.0/Term/ANSIColor.pm
12
+ @colors = (31..36).to_a
13
+ @size = @colors.size
14
+ @index = 0
17
15
  end
18
16
 
19
17
  def print o
20
18
  case o
21
19
  when "." then
22
- io.print "\e[#{@colors.next}m#{@chars.next}\e[0m"
20
+ io.print "\e[#{@colors[@index % @size]}m*\e[0m"
21
+ @index += 1
23
22
  when "E", "F" then
24
23
  io.print "\e[41m\e[37m#{o}\e[0m"
25
24
  else
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'minitest/unit'
4
4
 
5
- class Module
5
+ class Module # :nodoc:
6
6
  def infect_an_assertion meth, new_name, dont_flip = false # :nodoc:
7
7
  # warn "%-22p -> %p %p" % [meth, new_name, dont_flip]
8
8
  self.class_eval <<-EOM
@@ -17,39 +17,18 @@ class Module
17
17
  end
18
18
 
19
19
  ##
20
- # Create your own expectations from MiniTest::Assertions using a
21
- # flexible set of rules. If you don't like must/wont, then this
22
- # method is your friend. For an example of its usage see the bottom
23
- # of minitest/spec.rb.
20
+ # infect_with_assertions has been removed due to excessive clever.
21
+ # Use infect_an_assertion directly instead.
24
22
 
25
23
  def infect_with_assertions(pos_prefix, neg_prefix,
26
24
  skip_re,
27
25
  dont_flip_re = /\c0/,
28
26
  map = {})
29
- MiniTest::Assertions.public_instance_methods(false).sort.each do |meth|
30
- meth = meth.to_s
31
-
32
- new_name = case meth
33
- when /^assert/ then
34
- meth.sub(/^assert/, pos_prefix.to_s)
35
- when /^refute/ then
36
- meth.sub(/^refute/, neg_prefix.to_s)
37
- end
38
- next unless new_name
39
- next if new_name =~ skip_re
40
-
41
- regexp, replacement = map.find { |re, _| new_name =~ re }
42
- new_name.sub! regexp, replacement if replacement
43
-
44
- puts "\n##\n# :method: #{new_name}\n# See MiniTest::Assertions##{meth}" if
45
- $0 == __FILE__
46
-
47
- infect_an_assertion meth, new_name, new_name =~ dont_flip_re
48
- end
27
+ abort "infect_with_assertions is dead. Use infect_an_assertion directly"
49
28
  end
50
29
  end
51
30
 
52
- module Kernel
31
+ module Kernel # :nodoc:
53
32
  ##
54
33
  # Describe a series of expectations for a given target +desc+.
55
34
  #
@@ -96,7 +75,7 @@ end
96
75
  ##
97
76
  # MiniTest::Spec -- The faster, better, less-magical spec framework!
98
77
  #
99
- # For a list of expectations, see Object.
78
+ # For a list of expectations, see MiniTest::Expectations.
100
79
 
101
80
  class MiniTest::Spec < MiniTest::Unit::TestCase
102
81
  ##
@@ -136,6 +115,9 @@ class MiniTest::Spec < MiniTest::Unit::TestCase
136
115
  @@current_spec
137
116
  end
138
117
 
118
+ ##
119
+ # Returns the children of this spec"
120
+
139
121
  def self.children
140
122
  @children ||= []
141
123
  end
@@ -225,152 +207,275 @@ class MiniTest::Spec < MiniTest::Unit::TestCase
225
207
  # :startdoc:
226
208
  end
227
209
 
228
- Object.infect_with_assertions(:must, :wont,
229
- /^(must|wont)$|wont_(throw)|
230
- must_(block|not?_|nothing|raise$)/x,
231
- /(must|wont)_(include|respond_to)/,
232
- /(must_throw)s/ => '\1',
233
- /(?!not)_same/ => '_be_same_as',
234
- /_in_/ => '_be_within_',
235
- /_operator/ => '_be',
236
- /_includes/ => '_include',
237
- /(must|wont)_(.*_of|nil|silent|empty)/ => '\1_be_\2',
238
- /must_raises/ => 'must_raise')
210
+ module MiniTest::Expectations
211
+ ##
212
+ # See MiniTest::Assertions#assert_empty.
213
+ #
214
+ # collection.must_be_empty
215
+ #
216
+ # :method: must_be_empty
239
217
 
240
- class Object
241
- alias :must_be_close_to :must_be_within_delta
242
- alias :wont_be_close_to :wont_be_within_delta
243
-
244
- if $0 == __FILE__ then
245
- { "must" => "assert", "wont" => "refute" }.each do |a, b|
246
- puts "\n"
247
- puts "##"
248
- puts "# :method: #{a}_be_close_to"
249
- puts "# See MiniTest::Assertions##{b}_in_delta"
250
- end
251
- end
218
+ infect_an_assertion :assert_empty, :must_be_empty
252
219
 
253
220
  ##
254
- # :method: must_be
255
- # See MiniTest::Assertions#assert_operator
221
+ # See MiniTest::Assertions#assert_equal
222
+ #
223
+ # a.must_equal b
224
+ #
225
+ # :method: must_equal
226
+
227
+ infect_an_assertion :assert_equal, :must_equal
256
228
 
257
229
  ##
258
- # :method: must_be_close_to
259
230
  # See MiniTest::Assertions#assert_in_delta
231
+ #
232
+ # n.must_be_close_to m [, delta]
233
+ #
234
+ # :method: must_be_within_delta
260
235
 
261
- ##
262
- # :method: must_be_empty
263
- # See MiniTest::Assertions#assert_empty
236
+ infect_an_assertion :assert_in_delta, :must_be_close_to
264
237
 
265
- ##
266
- # :method: must_be_instance_of
267
- # See MiniTest::Assertions#assert_instance_of
238
+ alias :must_be_within_delta :must_be_close_to
268
239
 
269
240
  ##
270
- # :method: must_be_kind_of
271
- # See MiniTest::Assertions#assert_kind_of
241
+ # See MiniTest::Assertions#assert_in_epsilon
242
+ #
243
+ # n.must_be_within_epsilon m [, epsilon]
244
+ #
245
+ # :method: must_be_within_epsilon
272
246
 
273
- ##
274
- # :method: must_be_nil
275
- # See MiniTest::Assertions#assert_nil
247
+ infect_an_assertion :assert_in_epsilon, :must_be_within_epsilon
276
248
 
277
249
  ##
278
- # :method: must_be_same_as
279
- # See MiniTest::Assertions#assert_same
250
+ # See MiniTest::Assertions#assert_includes
251
+ #
252
+ # collection.must_include obj
253
+ #
254
+ # :method: must_include
280
255
 
281
- ##
282
- # :method: must_be_silent
283
- # See MiniTest::Assertions#assert_silent
256
+ infect_an_assertion :assert_includes, :must_include, :reverse
284
257
 
285
258
  ##
286
- # :method: must_be_within_delta
287
- # See MiniTest::Assertions#assert_in_delta
259
+ # See MiniTest::Assertions#assert_instance_of
260
+ #
261
+ # obj.must_be_instance_of klass
262
+ #
263
+ # :method: must_be_instance_of
264
+
265
+ infect_an_assertion :assert_instance_of, :must_be_instance_of
288
266
 
289
267
  ##
290
- # :method: must_be_within_epsilon
291
- # See MiniTest::Assertions#assert_in_epsilon
268
+ # See MiniTest::Assertions#assert_kind_of
269
+ #
270
+ # obj.must_be_kind_of mod
271
+ #
272
+ # :method: must_be_kind_of
273
+
274
+ infect_an_assertion :assert_kind_of, :must_be_kind_of
292
275
 
293
276
  ##
294
- # :method: must_equal
295
- # See MiniTest::Assertions#assert_equal
277
+ # See MiniTest::Assertions#assert_match
278
+ #
279
+ # a.must_match b
280
+ #
281
+ # :method: must_match
282
+
283
+ infect_an_assertion :assert_match, :must_match
296
284
 
297
285
  ##
298
- # :method: must_include
299
- # See MiniTest::Assertions#assert_includes
286
+ # See MiniTest::Assertions#assert_nil
287
+ #
288
+ # obj.must_be_nil
289
+ #
290
+ # :method: must_be_nil
291
+
292
+ infect_an_assertion :assert_nil, :must_be_nil
300
293
 
301
294
  ##
302
- # :method: must_match
303
- # See MiniTest::Assertions#assert_match
295
+ # See MiniTest::Assertions#assert_operator
296
+ #
297
+ # n.must_be :<=, 42
298
+ #
299
+ # :method: must_be
300
+
301
+ infect_an_assertion :assert_operator, :must_be
304
302
 
305
303
  ##
306
- # :method: must_output
307
304
  # See MiniTest::Assertions#assert_output
305
+ #
306
+ # proc { ... }.must_output out_or_nil [, err]
307
+ #
308
+ # :method: must_output
309
+
310
+ infect_an_assertion :assert_output, :must_output
308
311
 
309
312
  ##
310
- # :method: must_raise
311
313
  # See MiniTest::Assertions#assert_raises
314
+ #
315
+ # proc { ... }.must_raise exception
316
+ #
317
+ # :method: must_raise
318
+
319
+ infect_an_assertion :assert_raises, :must_raise
312
320
 
313
321
  ##
314
- # :method: must_respond_to
315
322
  # See MiniTest::Assertions#assert_respond_to
323
+ #
324
+ # obj.must_respond_to msg
325
+ #
326
+ # :method: must_respond_to
327
+
328
+ infect_an_assertion :assert_respond_to, :must_respond_to, :reverse
316
329
 
317
330
  ##
318
- # :method: must_send
319
- # See MiniTest::Assertions#assert_send
331
+ # See MiniTest::Assertions#assert_same
332
+ #
333
+ # a.must_be_same_as b
334
+ #
335
+ # :method: must_be_same_as
336
+
337
+ infect_an_assertion :assert_same, :must_be_same_as
320
338
 
321
339
  ##
322
- # :method: must_throw
323
- # See MiniTest::Assertions#assert_throws
340
+ # See MiniTest::Assertions#assert_send
341
+ # TODO: remove me
342
+ #
343
+ # a.must_send
344
+ #
345
+ # :method: must_send
346
+
347
+ infect_an_assertion :assert_send, :must_send
324
348
 
325
349
  ##
326
- # :method: wont_be
327
- # See MiniTest::Assertions#refute_operator
350
+ # See MiniTest::Assertions#assert_silent
351
+ #
352
+ # proc { ... }.must_be_silent
353
+ #
354
+ # :method: must_be_silent
355
+
356
+ infect_an_assertion :assert_silent, :must_be_silent
328
357
 
329
358
  ##
330
- # :method: wont_be_close_to
331
- # See MiniTest::Assertions#refute_in_delta
359
+ # See MiniTest::Assertions#assert_throws
360
+ #
361
+ # proc { ... }.must_throw sym
362
+ #
363
+ # :method: must_throw
364
+
365
+ infect_an_assertion :assert_throws, :must_throw
332
366
 
333
367
  ##
334
- # :method: wont_be_empty
335
368
  # See MiniTest::Assertions#refute_empty
369
+ #
370
+ # collection.wont_be_empty
371
+ #
372
+ # :method: wont_be_empty
373
+
374
+ infect_an_assertion :refute_empty, :wont_be_empty
336
375
 
337
376
  ##
338
- # :method: wont_be_instance_of
339
- # See MiniTest::Assertions#refute_instance_of
377
+ # See MiniTest::Assertions#refute_equal
378
+ #
379
+ # a.wont_equal b
380
+ #
381
+ # :method: wont_equal
382
+
383
+ infect_an_assertion :refute_equal, :wont_equal
340
384
 
341
385
  ##
342
- # :method: wont_be_kind_of
343
- # See MiniTest::Assertions#refute_kind_of
386
+ # See MiniTest::Assertions#refute_in_delta
387
+ #
388
+ # n.wont_be_close_to m [, delta]
389
+ #
390
+ # :method: wont_be_within_delta
391
+
392
+ infect_an_assertion :refute_in_delta, :wont_be_within_delta
393
+
394
+ alias :wont_be_close_to :wont_be_within_delta
395
+ # FIX: reverse aliases
344
396
 
345
397
  ##
346
- # :method: wont_be_nil
347
- # See MiniTest::Assertions#refute_nil
398
+ # See MiniTest::Assertions#refute_in_epsilon
399
+ #
400
+ # n.wont_be_within_epsilon m [, epsilon]
401
+ #
402
+ # :method: wont_be_within_epsilon
403
+
404
+ infect_an_assertion :refute_in_epsilon, :wont_be_within_epsilon
348
405
 
349
406
  ##
350
- # :method: wont_be_same_as
351
- # See MiniTest::Assertions#refute_same
407
+ # See MiniTest::Assertions#refute_includes
408
+ #
409
+ # collection.wont_include obj
410
+ #
411
+ # :method: wont_include
412
+
413
+ infect_an_assertion :refute_includes, :wont_include, :reverse
352
414
 
353
415
  ##
354
- # :method: wont_be_within_delta
355
- # See MiniTest::Assertions#refute_in_delta
416
+ # See MiniTest::Assertions#refute_instance_of
417
+ #
418
+ # obj.wont_be_instance_of klass
419
+ #
420
+ # :method: wont_be_instance_of
421
+
422
+ infect_an_assertion :refute_instance_of, :wont_be_instance_of
356
423
 
357
424
  ##
358
- # :method: wont_be_within_epsilon
359
- # See MiniTest::Assertions#refute_in_epsilon
425
+ # See MiniTest::Assertions#refute_kind_of
426
+ #
427
+ # obj.wont_be_kind_of mod
428
+ #
429
+ # :method: wont_be_kind_of
430
+
431
+ infect_an_assertion :refute_kind_of, :wont_be_kind_of
360
432
 
361
433
  ##
362
- # :method: wont_equal
363
- # See MiniTest::Assertions#refute_equal
434
+ # See MiniTest::Assertions#refute_match
435
+ #
436
+ # a.wont_match b
437
+ #
438
+ # :method: wont_match
439
+
440
+ infect_an_assertion :refute_match, :wont_match
364
441
 
365
442
  ##
366
- # :method: wont_include
367
- # See MiniTest::Assertions#refute_includes
443
+ # See MiniTest::Assertions#refute_nil
444
+ #
445
+ # obj.wont_be_nil
446
+ #
447
+ # :method: wont_be_nil
448
+
449
+ infect_an_assertion :refute_nil, :wont_be_nil
368
450
 
369
451
  ##
370
- # :method: wont_match
371
- # See MiniTest::Assertions#refute_match
452
+ # See MiniTest::Assertions#refute_operator
453
+ #
454
+ # n.wont_be :<=, 42
455
+ #
456
+ # :method: wont_be
457
+
458
+ infect_an_assertion :refute_operator, :wont_be
372
459
 
373
460
  ##
374
- # :method: wont_respond_to
375
461
  # See MiniTest::Assertions#refute_respond_to
462
+ #
463
+ # obj.wont_respond_to msg
464
+ #
465
+ # :method: wont_respond_to
466
+
467
+ infect_an_assertion :refute_respond_to, :wont_respond_to, :reverse
468
+
469
+ ##
470
+ # See MiniTest::Assertions#refute_same
471
+ #
472
+ # a.wont_be_same_as b
473
+ #
474
+ # :method: wont_be_same_as
475
+
476
+ infect_an_assertion :refute_same, :wont_be_same_as
477
+ end
478
+
479
+ class Object
480
+ include MiniTest::Expectations
376
481
  end
@@ -146,7 +146,7 @@ module MiniTest
146
146
 
147
147
  def mu_pp obj
148
148
  s = obj.inspect
149
- s = s.force_encoding Encoding.default_external if defined? Encoding
149
+ s = s.encode Encoding.default_external if defined? Encoding
150
150
  s
151
151
  end
152
152
 
@@ -614,7 +614,7 @@ module MiniTest
614
614
  end
615
615
 
616
616
  class Unit
617
- VERSION = "2.3.1" # :nodoc:
617
+ VERSION = "2.4.0" # :nodoc:
618
618
 
619
619
  attr_accessor :report, :failures, :errors, :skips # :nodoc:
620
620
  attr_accessor :test_count, :assertion_count # :nodoc:
@@ -52,7 +52,25 @@ class TestMiniTestMock < MiniTest::Unit::TestCase
52
52
  @mock.sum
53
53
  end
54
54
 
55
- assert_equal "mocked method 'sum' expects 2 arguments, got 0", e.message
55
+ assert_equal "mocked method :sum expects 2 arguments, got 0", e.message
56
+ end
57
+
58
+ def test_return_mock_does_not_raise
59
+ retval = MiniTest::Mock.new
60
+ mock = MiniTest::Mock.new
61
+ mock.expect(:foo, retval)
62
+ mock.foo
63
+
64
+ assert mock.verify
65
+ end
66
+
67
+ def test_mock_args_does_not_raise
68
+ arg = MiniTest::Mock.new
69
+ mock = MiniTest::Mock.new
70
+ mock.expect(:foo, nil, [arg])
71
+ mock.foo(arg)
72
+
73
+ assert mock.verify
56
74
  end
57
75
 
58
76
  def test_blow_up_on_wrong_arguments
@@ -75,7 +93,7 @@ class TestMiniTestMock < MiniTest::Unit::TestCase
75
93
  @mock.bar
76
94
  end
77
95
 
78
- expected = "unmocked method 'bar', expected one of 'foo', 'meaning_of_life'"
96
+ expected = "unmocked method :bar, expected one of [:foo, :meaning_of_life]"
79
97
 
80
98
  assert_equal expected, e.message
81
99
  end
@@ -83,10 +101,10 @@ class TestMiniTestMock < MiniTest::Unit::TestCase
83
101
  def test_assign_per_mock_return_values
84
102
  a = MiniTest::Mock.new
85
103
  b = MiniTest::Mock.new
86
-
104
+
87
105
  a.expect(:foo, :a)
88
106
  b.expect(:foo, :b)
89
-
107
+
90
108
  assert_equal :a, a.foo
91
109
  assert_equal :b, b.foo
92
110
  end
@@ -102,7 +120,7 @@ class TestMiniTestMock < MiniTest::Unit::TestCase
102
120
  @mock.expect :kind_of?, true, [Fixnum]
103
121
  @mock.expect :==, true, [1]
104
122
 
105
- assert @mock.kind_of?(Fixnum), "didn't mock :kind_of?"
123
+ assert @mock.kind_of?(Fixnum), "didn't mock :kind_of\?"
106
124
  assert @mock == 1, "didn't mock :=="
107
125
  end
108
126
 
@@ -6,6 +6,7 @@ MiniTest::Unit.autorun
6
6
 
7
7
  module MyModule; end
8
8
  class AnError < StandardError; include MyModule; end
9
+ class ImmutableString < String; def inspect; super.freeze; end; end
9
10
 
10
11
  class TestMiniTestUnit < MiniTest::Unit::TestCase
11
12
  pwd = Pathname.new(File.expand_path(Dir.pwd))
@@ -40,12 +41,12 @@ Finished tests in 0.00
40
41
  MiniTest::Unit::TestCase.reset
41
42
  @tu = MiniTest::Unit.new
42
43
  @output = StringIO.new("")
44
+ MiniTest::Unit.runner = nil # protect the outer runner from the inner tests
43
45
  MiniTest::Unit.output = @output
44
46
  end
45
47
 
46
48
  def teardown
47
49
  MiniTest::Unit.output = $stdout
48
- MiniTest::Unit.runner = nil
49
50
  Object.send :remove_const, :ATestCase if defined? ATestCase
50
51
  end
51
52
 
@@ -1221,6 +1222,11 @@ FILE:LINE:in `test_assert_raises_triggered_subclass'
1221
1222
  @tc.pass
1222
1223
  end
1223
1224
 
1225
+ def test_prints
1226
+ printer = Class.new { extend MiniTest::Assertions }
1227
+ @tc.assert_equal '"test"', printer.mu_pp(ImmutableString.new 'test')
1228
+ end
1229
+
1224
1230
  def test_refute
1225
1231
  @assertion_count = 2
1226
1232
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minitest
3
3
  version: !ruby/object:Gem::Version
4
- hash: 1
4
+ hash: 31
5
5
  prerelease:
6
6
  segments:
7
7
  - 2
8
- - 3
9
- - 1
10
- version: 2.3.1
8
+ - 4
9
+ - 0
10
+ version: 2.4.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ryan Davis
@@ -36,39 +36,23 @@ cert_chain:
36
36
  FBHgymkyj/AOSqKRIpXPhjC6
37
37
  -----END CERTIFICATE-----
38
38
 
39
- date: 2011-06-23 00:00:00 Z
39
+ date: 2011-08-10 00:00:00 Z
40
40
  dependencies:
41
- - !ruby/object:Gem::Dependency
42
- name: minitest
43
- prerelease: false
44
- requirement: &id001 !ruby/object:Gem::Requirement
45
- none: false
46
- requirements:
47
- - - ">="
48
- - !ruby/object:Gem::Version
49
- hash: 3
50
- segments:
51
- - 2
52
- - 3
53
- - 0
54
- version: 2.3.0
55
- type: :development
56
- version_requirements: *id001
57
41
  - !ruby/object:Gem::Dependency
58
42
  name: hoe
59
43
  prerelease: false
60
- requirement: &id002 !ruby/object:Gem::Requirement
44
+ requirement: &id001 !ruby/object:Gem::Requirement
61
45
  none: false
62
46
  requirements:
63
47
  - - ~>
64
48
  - !ruby/object:Gem::Version
65
- hash: 17
49
+ hash: 23
66
50
  segments:
67
51
  - 2
68
- - 9
69
- version: "2.9"
52
+ - 10
53
+ version: "2.10"
70
54
  type: :development
71
- version_requirements: *id002
55
+ version_requirements: *id001
72
56
  description: |-
73
57
  minitest provides a complete suite of testing facilities supporting
74
58
  TDD, BDD, mocking, and benchmarking.
@@ -90,7 +74,7 @@ description: |-
90
74
  framework.
91
75
 
92
76
  minitest/pride shows pride in testing and adds coloring to your test
93
- output.
77
+ output. I guess it is an example of how to write IO pipes too. :P
94
78
 
95
79
  minitest/unit is meant to have a clean implementation for language
96
80
  implementors that need a minimal set of methods to bootstrap a working
@@ -125,7 +109,7 @@ files:
125
109
  - test/test_minitest_spec.rb
126
110
  - test/test_minitest_unit.rb
127
111
  - .gemtest
128
- homepage: http://rubyforge.org/projects/bfts
112
+ homepage: https://github.com/seattlerb/minitest
129
113
  licenses: []
130
114
 
131
115
  post_install_message:
@@ -155,7 +139,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
155
139
  requirements: []
156
140
 
157
141
  rubyforge_project: bfts
158
- rubygems_version: 1.8.2
142
+ rubygems_version: 1.8.5
159
143
  signing_key:
160
144
  specification_version: 3
161
145
  summary: minitest provides a complete suite of testing facilities supporting TDD, BDD, mocking, and benchmarking
metadata.gz.sig CHANGED
@@ -1,3 +1 @@
1
- ���>���*�:��.>a���FY<����D�V���in�ǻ٢� ��U��6��on��9��n���t�:�q�,#�My���������Ց O^�v6� 55i���&oجs[p[�@㯟�ZqK�@Z
2
- �D~dB���OP�n7`|mˍ
3
- T����6 ��O���h�+7!��]�
1
+ ����MqyN�䁃��0�pW®�f����8^���e;%���BEy�9��v>��q����2����zc ��<J�����H�vg7uh������ՙ� �� V����V���H�^w)_3���,(+��B�������exĨ�3�D�c�R�����C�m2�NF��˩�