minitest 2.0.1 → 2.0.2

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.tar.gz.sig CHANGED
Binary file
@@ -1,3 +1,13 @@
1
+ === 2.0.2 / 2010-12-24
2
+
3
+ * 1 minor enhancement:
4
+
5
+ * Completed doco on minitest/benchmark for specs.
6
+
7
+ * 1 bug fix:
8
+
9
+ * Benchmarks in specs that didn't call bench_range would die. (zzak).
10
+
1
11
  === 2.0.1 / 2010-12-15
2
12
 
3
13
  * 4 minor enhancements:
@@ -4,11 +4,11 @@ require 'minitest/spec'
4
4
  class MiniTest::Unit
5
5
  attr_accessor :runner
6
6
 
7
- def run_benchmarks
7
+ def run_benchmarks # :nodoc:
8
8
  _run_anything :benchmark
9
9
  end
10
10
 
11
- def benchmark_suite_header suite
11
+ def benchmark_suite_header suite # :nodoc:
12
12
  "\n#{suite}\t#{suite.bench_range.join("\t")}"
13
13
  end
14
14
 
@@ -295,27 +295,63 @@ class MiniTest::Unit
295
295
  end
296
296
 
297
297
  class MiniTest::Spec
298
+ ##
299
+ # This is used to define a new benchmark method. You usually don't
300
+ # use this directly and is intended for those needing to write new
301
+ # performance curve fits (eg: you need a specific polynomial fit).
302
+ #
303
+ # See ::bench_performance_linear for an example of how to use this.
304
+
298
305
  def self.bench name, &block
299
306
  define_method "bench_#{name.gsub(/\W+/, '_')}", &block
300
307
  end
301
308
 
302
309
  def self.bench_range &block
310
+ return super unless block
311
+
303
312
  meta = (class << self; self; end)
304
313
  meta.send :define_method, "bench_range", &block
305
314
  end
306
315
 
316
+ ##
317
+ # Create a benchmark that verifies that the performance is linear.
318
+ #
319
+ # describe "my class" do
320
+ # bench_performance_linear "fast_algorithm", 0.9999 do
321
+ # @obj.fast_algorithm
322
+ # end
323
+ # end
324
+
307
325
  def self.bench_performance_linear name, threshold = 0.9, &work
308
326
  bench name do
309
327
  assert_performance_linear threshold, &work
310
328
  end
311
329
  end
312
330
 
331
+ ##
332
+ # Create a benchmark that verifies that the performance is constant.
333
+ #
334
+ # describe "my class" do
335
+ # bench_performance_constant "zoom_algorithm!" do
336
+ # @obj.zoom_algorithm!
337
+ # end
338
+ # end
339
+
313
340
  def self.bench_performance_constant name, threshold = 0.99, &work
314
341
  bench name do
315
342
  assert_performance_constant threshold, &work
316
343
  end
317
344
  end
318
345
 
346
+ ##
347
+ # Create a benchmark that verifies that the performance is exponential.
348
+ #
349
+ # describe "my class" do
350
+ # bench_performance_exponential "algorithm" do
351
+ # @obj.algorithm
352
+ # end
353
+ # end
354
+
319
355
  def self.bench_performance_exponential name, threshold = 0.99, &work
320
356
  bench name do
321
357
  assert_performance_exponential threshold, &work
@@ -1,17 +1,39 @@
1
1
  class MockExpectationError < StandardError; end
2
2
 
3
+ ##
4
+ # A simple and clean mock object framework.
5
+
3
6
  module MiniTest
7
+
8
+ ##
9
+ # All mock objects are an instance of Mock
10
+
4
11
  class Mock
5
- def initialize
12
+ def initialize # :nodoc:
6
13
  @expected_calls = {}
7
14
  @actual_calls = Hash.new {|h,k| h[k] = [] }
8
15
  end
9
16
 
17
+ ##
18
+ # Expect that method +name+ is called, optionally with +args+, and
19
+ # returns +retval+.
20
+ #
21
+ # @mock.expect(:meaning_of_life, 42)
22
+ # @mock.meaning_of_life # => 42
23
+ #
24
+ # @mock.expect(:do_something_with, true, [some_obj, true])
25
+ # @mock.do_something_with(some_obj, true) # => true
26
+
10
27
  def expect(name, retval, args=[])
11
28
  @expected_calls[name] = { :retval => retval, :args => args }
12
29
  self
13
30
  end
14
31
 
32
+ ##
33
+ # Verify that all methods were called as expected. Raises
34
+ # +MockExpectationError+ if the mock object was not called as
35
+ # expected.
36
+
15
37
  def verify
16
38
  @expected_calls.each_key do |name|
17
39
  expected = @expected_calls[name]
@@ -22,7 +44,7 @@ module MiniTest
22
44
  true
23
45
  end
24
46
 
25
- def method_missing(sym, *args)
47
+ def method_missing(sym, *args) # :nodoc:
26
48
  raise NoMethodError unless @expected_calls.has_key?(sym)
27
49
  raise ArgumentError unless @expected_calls[sym][:args].size == args.size
28
50
  retval = @expected_calls[sym][:retval]
@@ -31,7 +53,7 @@ module MiniTest
31
53
  end
32
54
 
33
55
  alias :original_respond_to? :respond_to?
34
- def respond_to?(sym)
56
+ def respond_to?(sym) # :nodoc:
35
57
  return true if @expected_calls.has_key?(sym)
36
58
  return original_respond_to?(sym)
37
59
  end
@@ -514,7 +514,7 @@ module MiniTest
514
514
  end
515
515
 
516
516
  class Unit
517
- VERSION = "2.0.1" # :nodoc:
517
+ VERSION = "2.0.2" # :nodoc:
518
518
 
519
519
  attr_accessor :report, :failures, :errors, :skips # :nodoc:
520
520
  attr_accessor :test_count, :assertion_count # :nodoc:
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 2
7
7
  - 0
8
- - 1
9
- version: 2.0.1
8
+ - 2
9
+ version: 2.0.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Ryan Davis
@@ -35,7 +35,7 @@ cert_chain:
35
35
  FBHgymkyj/AOSqKRIpXPhjC6
36
36
  -----END CERTIFICATE-----
37
37
 
38
- date: 2010-12-15 00:00:00 -08:00
38
+ date: 2010-12-24 00:00:00 -08:00
39
39
  default_executable:
40
40
  dependencies:
41
41
  - !ruby/object:Gem::Dependency
metadata.gz.sig CHANGED
@@ -1,2 +1,3 @@
1
- ~p�{��l��<=D%�S ��b��6�*�g�i��u!�&�i�!�Xv����Fv���
2
- fU.���m?^:0�#G����à���/�zM��Pw s��{����.�n�?Zv�C/���b�����H�/.�9�PM`�$���9�p]�ÔpC�d 5,牭]��] .Ao��r2Q4�Q�� �Jqd��8�+µƔ&�9�ȟhQ�P&/I�C[y`�� g��·������DS� M�o�q��
1
+ aJs�{t����Ä׵�[���%�R�Ɲ?B�MEE 骍R5m>c�i�^���� ƨP��hd�f� ΤΫ�>��v��1� (�#hă
2
+ Mf�z�%83l��`)Og���ћ��+ɐ ��p.���$�cg�![3��φ������cd��-�g$_��h@N|��۱�~�8g��N_OV�_/ 9��p
3
+ 6#�ĥ�O��*�{RG � ��@x�.�{ej2���x����v�nXHc,�F�c