minitest 4.5.0 → 4.6.0

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
data/History.txt CHANGED
@@ -1,3 +1,20 @@
1
+ === 4.6.0 / 2013-02-07
2
+
3
+ * 3 major enhancements:
4
+
5
+ * Removed ::reset_setup_teardown_hooks
6
+ * Removed the long deprecated assert_block
7
+ * Removed the long deprecated lifecycle hooks: add_(setup|teardown)_hook
8
+
9
+ * 1 minor enhancement:
10
+
11
+ * Allow filtering tests by suite name as well as test name. (lazyatom)
12
+
13
+ * 2 bug fixes:
14
+
15
+ * Made hex handling (eg object_ids) in mu_pp_for_diff more specific. (maxim)
16
+ * nodoc top-level module. (zzak)
17
+
1
18
  === 4.5.0 / 2013-01-22
2
19
 
3
20
  * 1 major enhancement:
data/README.txt CHANGED
@@ -324,6 +324,7 @@ minitest-should_syntax :: RSpec-style +x.should == y+ assertions for MiniTest
324
324
  minitest-shouldify :: Adding all manner of shoulds to MiniTest (bad idea)
325
325
  minitest-spec-magic :: Minitest::Spec extensions for Rails and beyond
326
326
  minitest-spec-rails :: Drop in MiniTest::Spec superclass for ActiveSupport::TestCase.
327
+ minitest-stub-const :: Stub constants for the duration of a block
327
328
  minitest-tags :: add tags for minitest
328
329
  minitest-wscolor :: Yet another test colorizer.
329
330
  minitest_owrapper :: Get tests results as a TestResult object.
data/lib/minitest/mock.rb CHANGED
@@ -1,10 +1,9 @@
1
- class MockExpectationError < StandardError # :nodoc:
2
- end # omg... worst bug ever. rdoc doesn't allow 1-liners
1
+ class MockExpectationError < StandardError; end # :nodoc:
3
2
 
4
3
  ##
5
4
  # A simple and clean mock object framework.
6
5
 
7
- module MiniTest
6
+ module MiniTest # :nodoc:
8
7
 
9
8
  ##
10
9
  # All mock objects are an instance of Mock
@@ -27,6 +27,12 @@ class ParallelEach
27
27
  self.class.new super
28
28
  end
29
29
 
30
+ def select(&block) # :nodoc:
31
+ self.class.new super
32
+ end
33
+
34
+ alias find_all select # :nodoc:
35
+
30
36
  ##
31
37
  # Starts N threads that yield each element to your block. Joins the
32
38
  # threads at the end.
data/lib/minitest/unit.rb CHANGED
@@ -172,8 +172,8 @@ module MiniTest
172
172
  # newlines and makes hex-values generic (like object_ids). This
173
173
  # uses mu_pp to do the first pass and then cleans it up.
174
174
 
175
- def mu_pp_for_diff obj # TODO: possibly rename
176
- mu_pp(obj).gsub(/\\n/, "\n").gsub(/0x[a-f0-9]+/m, '0xXXXXXX')
175
+ def mu_pp_for_diff obj
176
+ mu_pp(obj).gsub(/\\n/, "\n").gsub(/:0x[a-fA-F0-9]{4,}/m, ':0xXXXXXX')
177
177
  end
178
178
 
179
179
  def _assertions= n # :nodoc:
@@ -197,18 +197,6 @@ module MiniTest
197
197
  true
198
198
  end
199
199
 
200
- ##
201
- # Fails unless the block returns a true value.
202
- #
203
- # NOTE: This method is deprecated, use assert. It will be removed
204
- # on 2013-01-01."
205
-
206
- def assert_block msg = nil
207
- warn "NOTE: MiniTest::Unit::TestCase#assert_block is deprecated, use assert. It will be removed on 2013-01-01. Called from #{caller.first}"
208
- msg = message(msg) { "Expected block to return true value" }
209
- assert yield, msg
210
- end
211
-
212
200
  ##
213
201
  # Fails unless +obj+ is empty.
214
202
 
@@ -738,7 +726,7 @@ module MiniTest
738
726
  end
739
727
 
740
728
  class Unit # :nodoc:
741
- VERSION = "4.5.0" # :nodoc:
729
+ VERSION = "4.6.0" # :nodoc:
742
730
 
743
731
  attr_accessor :report, :failures, :errors, :skips # :nodoc:
744
732
  attr_accessor :test_count, :assertion_count # :nodoc:
@@ -908,7 +896,13 @@ module MiniTest
908
896
  filter = options[:filter] || '/./'
909
897
  filter = Regexp.new $1 if filter =~ /\/(.*)\//
910
898
 
911
- assertions = suite.send("#{type}_methods").grep(filter).map { |method|
899
+ all_test_methods = suite.send "#{type}_methods"
900
+
901
+ filtered_test_methods = all_test_methods.find_all { |m|
902
+ filter === m || filter === "#{suite}##{m}"
903
+ }
904
+
905
+ assertions = filtered_test_methods.map { |method|
912
906
  inst = suite.new method
913
907
  inst._assertions = 0
914
908
 
@@ -982,7 +976,7 @@ module MiniTest
982
976
  @report = []
983
977
  @errors = @failures = @skips = 0
984
978
  @verbose = false
985
- @mutex = Mutex.new if defined?(Mutex)
979
+ @mutex = defined?(Mutex) ? Mutex.new : nil
986
980
  end
987
981
 
988
982
  def synchronize # :nodoc:
@@ -1200,79 +1194,6 @@ module MiniTest
1200
1194
  def after_teardown; end
1201
1195
  end
1202
1196
 
1203
- module Deprecated # :nodoc:
1204
-
1205
- ##
1206
- # This entire module is deprecated and slated for removal on 2013-01-01.
1207
-
1208
- module Hooks
1209
- def run_setup_hooks # :nodoc:
1210
- _run_hooks self.class.setup_hooks
1211
- end
1212
-
1213
- def _run_hooks hooks # :nodoc:
1214
- hooks.each do |hook|
1215
- if hook.respond_to?(:arity) && hook.arity == 1
1216
- hook.call(self)
1217
- else
1218
- hook.call
1219
- end
1220
- end
1221
- end
1222
-
1223
- def run_teardown_hooks # :nodoc:
1224
- _run_hooks self.class.teardown_hooks.reverse
1225
- end
1226
- end
1227
-
1228
- ##
1229
- # This entire module is deprecated and slated for removal on 2013-01-01.
1230
-
1231
- module HooksCM
1232
- ##
1233
- # Adds a block of code that will be executed before every
1234
- # TestCase is run.
1235
- #
1236
- # NOTE: This method is deprecated, use before/after_setup. It
1237
- # will be removed on 2013-01-01.
1238
-
1239
- def add_setup_hook arg=nil, &block
1240
- warn "NOTE: MiniTest::Unit::TestCase.add_setup_hook is deprecated, use before/after_setup via a module (and call super!). It will be removed on 2013-01-01. Called from #{caller.first}"
1241
- hook = arg || block
1242
- @setup_hooks << hook
1243
- end
1244
-
1245
- def setup_hooks # :nodoc:
1246
- if superclass.respond_to? :setup_hooks then
1247
- superclass.setup_hooks
1248
- else
1249
- []
1250
- end + @setup_hooks
1251
- end
1252
-
1253
- ##
1254
- # Adds a block of code that will be executed after every
1255
- # TestCase is run.
1256
- #
1257
- # NOTE: This method is deprecated, use before/after_teardown. It
1258
- # will be removed on 2013-01-01.
1259
-
1260
- def add_teardown_hook arg=nil, &block
1261
- warn "NOTE: MiniTest::Unit::TestCase#add_teardown_hook is deprecated, use before/after_teardown. It will be removed on 2013-01-01. Called from #{caller.first}"
1262
- hook = arg || block
1263
- @teardown_hooks << hook
1264
- end
1265
-
1266
- def teardown_hooks # :nodoc:
1267
- if superclass.respond_to? :teardown_hooks then
1268
- superclass.teardown_hooks
1269
- else
1270
- []
1271
- end + @teardown_hooks
1272
- end
1273
- end
1274
- end
1275
-
1276
1197
  ##
1277
1198
  # Subclass TestCase to create your own tests. Typically you'll want a
1278
1199
  # TestCase subclass per implementation class.
@@ -1281,8 +1202,6 @@ module MiniTest
1281
1202
 
1282
1203
  class TestCase
1283
1204
  include LifecycleHooks
1284
- include Deprecated::Hooks
1285
- extend Deprecated::HooksCM # UGH... I can't wait 'til 2013!
1286
1205
  include Guard
1287
1206
  extend Guard
1288
1207
 
@@ -1420,7 +1339,6 @@ module MiniTest
1420
1339
 
1421
1340
  def self.inherited klass # :nodoc:
1422
1341
  @@test_suites[klass] = true
1423
- klass.reset_setup_teardown_hooks
1424
1342
  super
1425
1343
  end
1426
1344
 
@@ -1468,14 +1386,6 @@ module MiniTest
1468
1386
 
1469
1387
  def teardown; end
1470
1388
 
1471
- def self.reset_setup_teardown_hooks # :nodoc:
1472
- # also deprecated... believe it.
1473
- @setup_hooks = []
1474
- @teardown_hooks = []
1475
- end
1476
-
1477
- reset_setup_teardown_hooks
1478
-
1479
1389
  include MiniTest::Assertions
1480
1390
  end # class TestCase
1481
1391
  end # class Unit
@@ -17,23 +17,6 @@ class TestMiniTestUnit < MetaMetaMetaTestCase
17
17
  "#{MINITEST_BASE_DIR}/test.rb:139:in `run'",
18
18
  "#{MINITEST_BASE_DIR}/test.rb:106:in `run'"]
19
19
 
20
- def test_wtf
21
- $hook_value = nil
22
-
23
- capture_io do # don't care about deprecation
24
- MiniTest::Unit::TestCase.add_setup_hook do
25
- $hook_value = 42
26
- end
27
- end
28
-
29
- run_setup_hooks
30
-
31
- assert_equal 42, $hook_value
32
- assert_equal [Proc], MiniTest::Unit::TestCase.setup_hooks.map(&:class)
33
- MiniTest::Unit::TestCase.reset_setup_teardown_hooks
34
- assert_equal [], MiniTest::Unit::TestCase.setup_hooks.map(&:class)
35
- end
36
-
37
20
  def test_class_puke_with_assertion_failed
38
21
  exception = MiniTest::Assertion.new "Oh no!"
39
22
  exception.set_backtrace ["unhappy"]
@@ -389,6 +372,65 @@ class TestMiniTestRunner < MetaMetaMetaTestCase
389
372
  assert_report expected, %w[--name /some|thing/ --seed 42]
390
373
  end
391
374
 
375
+ def assert_filtering name, expected, a = false
376
+ args = %W[--name #{name} --seed 42]
377
+
378
+ alpha = Class.new MiniTest::Unit::TestCase do
379
+ define_method :test_something do
380
+ assert a
381
+ end
382
+ end
383
+ Object.const_set(:Alpha, alpha)
384
+
385
+ beta = Class.new MiniTest::Unit::TestCase do
386
+ define_method :test_something do
387
+ assert true
388
+ end
389
+ end
390
+ Object.const_set(:Beta, beta)
391
+
392
+ assert_report expected, args
393
+ ensure
394
+ Object.send :remove_const, :Alpha
395
+ Object.send :remove_const, :Beta
396
+ end
397
+
398
+ def test_run_filtered_including_suite_name
399
+ expected = clean <<-EOM
400
+ .
401
+
402
+ Finished tests in 0.00
403
+
404
+ 1 tests, 1 assertions, 0 failures, 0 errors, 0 skips
405
+ EOM
406
+
407
+ assert_filtering "/Beta#test_something/", expected
408
+ end
409
+
410
+ def test_run_filtered_including_suite_name_string
411
+ expected = clean <<-EOM
412
+ .
413
+
414
+ Finished tests in 0.00
415
+
416
+ 1 tests, 1 assertions, 0 failures, 0 errors, 0 skips
417
+ EOM
418
+
419
+ assert_filtering "Beta#test_something", expected
420
+ end
421
+
422
+ def test_run_filtered_string_method_only
423
+ expected = clean <<-EOM
424
+ ..
425
+
426
+ Finished tests in 0.00
427
+
428
+ 2 tests, 2 assertions, 0 failures, 0 errors, 0 skips
429
+ EOM
430
+
431
+ assert_filtering "test_something", expected, :pass
432
+ end
433
+
392
434
  def test_run_passing
393
435
  Class.new MiniTest::Unit::TestCase do
394
436
  def test_something
@@ -722,30 +764,6 @@ class TestMiniTestUnitTestCase < MiniTest::Unit::TestCase
722
764
  end
723
765
  end
724
766
 
725
- def test_assert_block
726
- exp = ["NOTE: MiniTest::Unit::TestCase#assert_block is deprecated,",
727
- "use assert. It will be removed on 2013-01-01."].join " "
728
-
729
- out, err = capture_io do
730
- @tc.assert_block do
731
- true
732
- end
733
- end
734
-
735
- assert_equal "", out
736
- assert_match exp, err
737
- end
738
-
739
- def test_assert_block_triggered
740
- assert_output do
741
- util_assert_triggered "blah.\nExpected block to return true value." do
742
- @tc.assert_block "blah" do
743
- false
744
- end
745
- end
746
- end
747
- end
748
-
749
767
  def test_assert_empty
750
768
  @assertion_count = 2
751
769
 
@@ -1372,7 +1390,7 @@ class TestMiniTestUnitTestCase < MiniTest::Unit::TestCase
1372
1390
 
1373
1391
  # These don't have corresponding refutes _on purpose_. They're
1374
1392
  # useless and will never be added, so don't bother.
1375
- ignores = %w[assert_block assert_output assert_raises assert_send
1393
+ ignores = %w[assert_output assert_raises assert_send
1376
1394
  assert_silent assert_throws]
1377
1395
 
1378
1396
  # These are test/unit methods. I'm not actually sure why they're still here
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: 43
4
+ hash: 39
5
5
  prerelease:
6
6
  segments:
7
7
  - 4
8
- - 5
8
+ - 6
9
9
  - 0
10
- version: 4.5.0
10
+ version: 4.6.0
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-01-23 00:00:00 Z
39
+ date: 2013-02-07 00:00:00 Z
40
40
  dependencies:
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rdoc
@@ -184,7 +184,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
184
184
  requirements: []
185
185
 
186
186
  rubyforge_project: bfts
187
- rubygems_version: 1.8.24
187
+ rubygems_version: 1.8.25
188
188
  signing_key:
189
189
  specification_version: 3
190
190
  summary: minitest provides a complete suite of testing facilities supporting TDD, BDD, mocking, and benchmarking
metadata.gz.sig CHANGED
Binary file