minitest 5.0.4 → 5.0.5

Sign up to get free protection for your applications and to get access to all the features.
data.tar.gz.sig CHANGED
Binary file
data/.autotest CHANGED
@@ -6,12 +6,26 @@ require 'autotest/rcov' if ENV['RCOV']
6
6
  Autotest.add_hook :initialize do |at|
7
7
  at.testlib = 'minitest/autorun'
8
8
 
9
- at.extra_class_map["MiniTest::Spec"] = "test/test_minitest_spec.rb"
10
- at.extra_class_map["TestMeta"] = "test/test_minitest_spec.rb"
11
- at.extra_class_map["TestMiniTestUnitTestCase"] = "test/test_minitest_unit.rb"
12
- at.extra_class_map["TestMiniTestUnit"] = "test/test_minitest_unit.rb"
13
- at.extra_class_map["TestMiniTestUnitRecording"]= "test/test_minitest_unit.rb"
14
- at.extra_class_map["TestMiniTestStub"] = "test/test_minitest_mock.rb"
9
+ bench_tests = %w(TestMinitestBenchmark)
10
+ mock_tests = %w(TestMinitestMock TestMinitestStub)
11
+ spec_tests = %w(TestMinitestReporter TestMetaStatic TestMeta
12
+ TestSpecInTestCase)
13
+ unit_tests = %w(TestMinitestGuard TestMinitestRunnable
14
+ TestMinitestRunner TestMinitestTest TestMinitestUnit
15
+ TestMinitestUnitInherited TestMinitestUnitOrder
16
+ TestMinitestUnitRecording TestMinitestUnitTestCase)
17
+
18
+ {
19
+ bench_tests => "test/minitest/test_minitest_benchmark.rb",
20
+ mock_tests => "test/minitest/test_minitest_mock.rb",
21
+ spec_tests => "test/minitest/test_minitest_reporter.rb",
22
+ unit_tests => "test/minitest/test_minitest_unit.rb",
23
+ }.each do |klasses, file|
24
+ klasses.each do |klass|
25
+ at.extra_class_map[klass] = file
26
+ end
27
+ end
28
+
15
29
  at.add_exception 'coverage.info'
16
30
  at.add_exception 'coverage'
17
31
  end
@@ -1,3 +1,14 @@
1
+ === 5.0.5 / 2013-06-20
2
+
3
+ * 6 bug fixes:
4
+
5
+ * DOH! Fixed the rest of the new casing on Minitest. (splattael)
6
+ * Fixed typo on minitest/mock rdoc. (mrgilman/guiceolin)
7
+ * Make Spec::DSL.describe_stack thread local to avoid failing on my own tests.
8
+ * Make a fake Time.now local to the tests so they won't interfere with real reporter timings.
9
+ * Make everything mockable by wrapping all 'special' methods in a smarter wrapper. (bestie)
10
+ * Raise ArgumentError if let name starts with 'test'. (johnmaxwell)
11
+
1
12
  === 5.0.4 / 2013-06-07
2
13
 
3
14
  * 5 minor enhancements:
data/README.txt CHANGED
@@ -194,7 +194,7 @@ Output is tab-delimited to make it easy to paste into a spreadsheet.
194
194
 
195
195
  describe MemeAsker do
196
196
  before do
197
- @meme = MiniTest::Mock.new
197
+ @meme = Minitest::Mock.new
198
198
  @meme_asker = MemeAsker.new @meme
199
199
  end
200
200
 
@@ -328,18 +328,18 @@ Expectations are put on Object (one level down) so the Worker
328
328
  fails.
329
329
 
330
330
  You can bypass `SimpleDelegate#method_missing` by extending the worker
331
- with `MiniTest::Expectations`. You can either do that in your setup at
331
+ with `Minitest::Expectations`. You can either do that in your setup at
332
332
  the instance level, like:
333
333
 
334
334
  before do
335
335
  @worker = Worker.new(Object.new)
336
- @worker.extend MiniTest::Expectations
336
+ @worker.extend Minitest::Expectations
337
337
  end
338
338
 
339
339
  or you can extend the Worker class (within the test file!), like:
340
340
 
341
341
  class Worker
342
- include ::MiniTest::Expectations
342
+ include ::Minitest::Expectations
343
343
  end
344
344
 
345
345
  === How to share code across test classes?
data/Rakefile CHANGED
@@ -38,8 +38,8 @@ task :specs do
38
38
  /must_raises/ => 'must_raise',
39
39
  }
40
40
 
41
- expectations = MiniTest::Expectations.public_instance_methods.map(&:to_s)
42
- assertions = MiniTest::Assertions.public_instance_methods.map(&:to_s)
41
+ expectations = Minitest::Expectations.public_instance_methods.map(&:to_s)
42
+ assertions = Minitest::Assertions.public_instance_methods.map(&:to_s)
43
43
 
44
44
  assertions.sort.each do |assertion|
45
45
  expectation = case assertion
@@ -63,7 +63,7 @@ task :specs do
63
63
  puts
64
64
  puts "##"
65
65
  puts "# :method: #{expectation}"
66
- puts "# See MiniTest::Assertions##{assertion}"
66
+ puts "# See Minitest::Assertions##{assertion}"
67
67
  puts
68
68
  puts "infect_an_assertion #{args.join ", "}"
69
69
  end
@@ -26,7 +26,7 @@ end # assert_equal 2, 2
26
26
  ###############################################################################
27
27
  # The specs generate:
28
28
 
29
- class ThingySpec < MiniTest::Spec
29
+ class ThingySpec < Minitest::Spec
30
30
  def setup
31
31
  super
32
32
  do_some_setup
@@ -4,7 +4,7 @@ require "optparse"
4
4
  # :include: README.txt
5
5
 
6
6
  module Minitest
7
- VERSION = "5.0.4" # :nodoc:
7
+ VERSION = "5.0.5" # :nodoc:
8
8
 
9
9
  @@installed_at_exit ||= false
10
10
  @@after_run = []
@@ -10,10 +10,28 @@ module Minitest # :nodoc:
10
10
  class Mock
11
11
  alias :__respond_to? :respond_to?
12
12
 
13
- skip_methods = %w(object_id respond_to_missing? inspect === to_s)
13
+ overridden_methods = %w(
14
+ ===
15
+ inspect
16
+ object_id
17
+ public_send
18
+ respond_to_missing?
19
+ send
20
+ to_s
21
+ )
14
22
 
15
23
  instance_methods.each do |m|
16
- undef_method m unless skip_methods.include?(m.to_s) || m =~ /^__/
24
+ undef_method m unless overridden_methods.include?(m.to_s) || m =~ /^__/
25
+ end
26
+
27
+ overridden_methods.map(&:to_sym).each do |method_id|
28
+ define_method method_id do |*args, &b|
29
+ if @expected_calls.has_key? method_id then
30
+ method_missing(method_id, *args, &b)
31
+ else
32
+ super(*args, &b)
33
+ end
34
+ end
17
35
  end
18
36
 
19
37
  def initialize # :nodoc:
@@ -42,11 +60,13 @@ module Minitest # :nodoc:
42
60
  # @mock.uses_any_string("foo") # => true
43
61
  # @mock.verify # => true
44
62
  #
45
- # @mock.expect(:uses_one_string, true, ["foo"]
63
+ # @mock.expect(:uses_one_string, true, ["foo"])
46
64
  # @mock.uses_one_string("bar") # => true
47
65
  # @mock.verify # => raises MockExpectationError
48
66
 
49
67
  def expect(name, retval, args=[], &blk)
68
+ name = name.to_sym
69
+
50
70
  if block_given?
51
71
  raise ArgumentError, "args ignored when block given" unless args.empty?
52
72
  @expected_calls[name] << { :retval => retval, :block => blk }
@@ -138,7 +158,7 @@ module Minitest # :nodoc:
138
158
  end
139
159
 
140
160
  def respond_to?(sym, include_private = false) # :nodoc:
141
- return true if @expected_calls.has_key?(sym.to_sym)
161
+ return true if @expected_calls.has_key? sym.to_sym
142
162
  return __respond_to?(sym, include_private)
143
163
  end
144
164
  end
@@ -143,9 +143,8 @@ class Minitest::Spec < Minitest::Test
143
143
  }.last
144
144
  end
145
145
 
146
- @@describe_stack = []
147
146
  def describe_stack # :nodoc:
148
- @@describe_stack
147
+ Thread.current[:describe_stack] ||= []
149
148
  end
150
149
 
151
150
  ##
@@ -223,6 +222,7 @@ class Minitest::Spec < Minitest::Test
223
222
  # Why use let instead of def? I honestly don't know.
224
223
 
225
224
  def let name, &block
225
+ raise ArgumentError, 'name cannot begin with "test"' if name.to_s =~ /\Atest/
226
226
  define_method name do
227
227
  @_memoized ||= {}
228
228
  @_memoized.fetch(name) { |k| @_memoized[k] = instance_eval(&block) }
@@ -74,6 +74,49 @@ class TestMinitestMock < Minitest::Test
74
74
  assert mock.verify
75
75
  end
76
76
 
77
+ def test_set_expectation_on_special_methods
78
+ mock = Minitest::Mock.new
79
+
80
+ mock.expect :object_id, "received object_id"
81
+ assert_equal "received object_id", mock.object_id
82
+
83
+ mock.expect :respond_to_missing?, "received respond_to_missing?"
84
+ assert_equal "received respond_to_missing?", mock.respond_to_missing?
85
+
86
+ mock.expect :===, "received ==="
87
+ assert_equal "received ===", mock.===
88
+
89
+ mock.expect :inspect, "received inspect"
90
+ assert_equal "received inspect", mock.inspect
91
+
92
+ mock.expect :to_s, "received to_s"
93
+ assert_equal "received to_s", mock.to_s
94
+
95
+ mock.expect :public_send, "received public_send"
96
+ assert_equal "received public_send", mock.public_send
97
+
98
+ mock.expect :send, "received send"
99
+ assert_equal "received send", mock.send
100
+
101
+ assert mock.verify
102
+ end
103
+
104
+ def test_expectations_can_be_satisfied_via_send
105
+ @mock.send :foo
106
+ @mock.send :meaning_of_life
107
+
108
+ assert @mock.verify
109
+ end
110
+
111
+ def test_expectations_can_be_satisfied_via_public_send
112
+ skip if RUBY_VERSION < "1.9"
113
+
114
+ @mock.public_send :foo
115
+ @mock.public_send :meaning_of_life
116
+
117
+ assert @mock.verify
118
+ end
119
+
77
120
  def test_blow_up_on_wrong_arguments
78
121
  @mock.foo
79
122
  @mock.meaning_of_life
@@ -286,18 +329,22 @@ class TestMinitestStub < Minitest::Test
286
329
  assert_equal @assertion_count, @tc.assertions
287
330
  end
288
331
 
332
+ class Time
333
+ def self.now
334
+ 24
335
+ end
336
+ end
337
+
289
338
  def assert_stub val_or_callable
290
339
  @assertion_count += 1
291
340
 
292
- Minitest::Test.synchronize do
293
- t = Time.now.to_i
294
-
295
- Time.stub :now, val_or_callable do
296
- @tc.assert_equal 42, Time.now
297
- end
341
+ t = Time.now.to_i
298
342
 
299
- @tc.assert_operator Time.now.to_i, :>=, t
343
+ Time.stub :now, val_or_callable do
344
+ @tc.assert_equal 42, Time.now
300
345
  end
346
+
347
+ @tc.assert_operator Time.now.to_i, :>=, t
301
348
  end
302
349
 
303
350
  def test_stub_private_module_method
@@ -345,15 +392,13 @@ class TestMinitestStub < Minitest::Test
345
392
  def test_stub_block_args
346
393
  @assertion_count += 1
347
394
 
348
- Minitest::Test.synchronize do
349
- t = Time.now.to_i
395
+ t = Time.now.to_i
350
396
 
351
- Time.stub :now, lambda { |n| n * 2 } do
352
- @tc.assert_equal 42, Time.now(21)
353
- end
354
-
355
- @tc.assert_operator Time.now.to_i, :>=, t
397
+ Time.stub :now, lambda { |n| n * 2 } do
398
+ @tc.assert_equal 42, Time.now(21)
356
399
  end
400
+
401
+ @tc.assert_operator Time.now.to_i, :>=, t
357
402
  end
358
403
 
359
404
  def test_stub_callable
@@ -551,6 +551,12 @@ describe Minitest::Spec, :let do
551
551
 
552
552
  _count.must_equal 2
553
553
  end
554
+
555
+ it 'raises an error if the name begins with "test"' do
556
+ describe "let" do
557
+ proc { let(:test_value) { true } }.must_raise ArgumentError
558
+ end
559
+ end
554
560
  end
555
561
 
556
562
  describe Minitest::Spec, :subject do
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: 63
4
+ hash: 61
5
5
  prerelease:
6
6
  segments:
7
7
  - 5
8
8
  - 0
9
- - 4
10
- version: 5.0.4
9
+ - 5
10
+ version: 5.0.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ryan Davis
@@ -36,7 +36,7 @@ cert_chain:
36
36
  FBHgymkyj/AOSqKRIpXPhjC6
37
37
  -----END CERTIFICATE-----
38
38
 
39
- date: 2013-06-07 00:00:00 Z
39
+ date: 2013-06-21 00:00:00 Z
40
40
  dependencies:
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rdoc
metadata.gz.sig CHANGED
Binary file