minitest 4.7.1 → 4.7.2

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/History.txt CHANGED
@@ -1,3 +1,10 @@
1
+ === 4.7.2 / 2013-04-18
2
+
3
+ * 2 bug fixes:
4
+
5
+ * Fixed inconsistency in refute_in_delta/epsilon. I double negatived my logic. (nettsundere)
6
+ * Fixed stubbing of module methods (eg Kernel#sleep). (steveklabnik)
7
+
1
8
  === 4.7.1 / 2013-04-09
2
9
 
3
10
  * 1 minor enhancement:
data/README.txt CHANGED
@@ -347,6 +347,7 @@ minitest-debugger :: Wraps assert so failed assertions drop into
347
347
  the ruby debugger.
348
348
  minitest-display :: Patches MiniTest to allow for an easily configurable output.
349
349
  minitest-emoji :: Print out emoji for your test passes, fails, and skips.
350
+ minitest-english :: Semantically symmetric aliases for assertions and expectations.
350
351
  minitest-excludes :: Clean API for excluding certain tests you
351
352
  don't want to run under certain conditions.
352
353
  minitest-firemock :: Makes your MiniTest mocks more resilient.
@@ -370,6 +371,7 @@ minitest-rails-capybara :: Capybara integration for MiniTest::Rails
370
371
  minitest-reporters :: Create customizable MiniTest output formats
371
372
  minitest-should_syntax :: RSpec-style +x.should == y+ assertions for MiniTest
372
373
  minitest-shouldify :: Adding all manner of shoulds to MiniTest (bad idea)
374
+ minitest-spec-context :: Provides rspec-ish context method to MiniTest::Spec
373
375
  minitest-spec-magic :: Minitest::Spec extensions for Rails and beyond
374
376
  minitest-spec-rails :: Drop in MiniTest::Spec superclass for ActiveSupport::TestCase.
375
377
  minitest-stub-const :: Stub constants for the duration of a block
@@ -399,7 +401,6 @@ Authors... Please send me a pull request with a description of your minitest ext
399
401
  * minitest-extra-assertions
400
402
  * minitest-rails-shoulda
401
403
  * minitest-spec
402
- * minitest-spec-context
403
404
  * minitest-spec-should
404
405
  * minitest-sugar
405
406
  * minitest_should
data/lib/minitest/hell.rb CHANGED
@@ -1,11 +1,13 @@
1
1
  require "minitest/parallel_each"
2
2
 
3
- class Minitest::Unit::TestCase # :nodoc:
3
+ # :stopdoc:
4
+ class Minitest::Unit::TestCase
4
5
  class << self
5
6
  alias :old_test_order :test_order
6
7
 
7
- def test_order # :nodoc:
8
+ def test_order
8
9
  :parallel
9
10
  end
10
11
  end
11
12
  end
13
+ # :startdoc:
data/lib/minitest/mock.rb CHANGED
@@ -166,7 +166,7 @@ class Object # :nodoc:
166
166
  def stub name, val_or_callable, &block
167
167
  new_name = "__minitest_stub__#{name}"
168
168
 
169
- metaclass = class << self; self; end
169
+ metaclass = self.class == Module ? self : class << self; self; end
170
170
 
171
171
  if respond_to? name and not methods.map(&:to_s).include? name.to_s then
172
172
  metaclass.send :define_method, name do |*args|
data/lib/minitest/spec.rb CHANGED
@@ -258,7 +258,7 @@ class MiniTest::Spec < MiniTest::Unit::TestCase
258
258
 
259
259
  extend DSL
260
260
 
261
- TYPES = DSL::TYPES
261
+ TYPES = DSL::TYPES # :nodoc:
262
262
  end
263
263
 
264
264
  ##
data/lib/minitest/unit.rb CHANGED
@@ -231,7 +231,9 @@ module MiniTest
231
231
 
232
232
  def assert_in_delta exp, act, delta = 0.001, msg = nil
233
233
  n = (exp - act).abs
234
- msg = message(msg) { "Expected |#{exp} - #{act}| (#{n}) to be < #{delta}"}
234
+ msg = message(msg) {
235
+ "Expected |#{exp} - #{act}| (#{n}) to be <= #{delta}"
236
+ }
235
237
  assert delta >= n, msg
236
238
  end
237
239
 
@@ -595,9 +597,9 @@ module MiniTest
595
597
  def refute_in_delta exp, act, delta = 0.001, msg = nil
596
598
  n = (exp - act).abs
597
599
  msg = message(msg) {
598
- "Expected |#{exp} - #{act}| (#{n}) to not be < #{delta}"
600
+ "Expected |#{exp} - #{act}| (#{n}) to not be <= #{delta}"
599
601
  }
600
- refute delta > n, msg
602
+ refute delta >= n, msg
601
603
  end
602
604
 
603
605
  ##
@@ -711,6 +713,9 @@ module MiniTest
711
713
  raise MiniTest::Skip, msg, bt
712
714
  end
713
715
 
716
+ ##
717
+ # Was this testcase skipped? Meant for #teardown.
718
+
714
719
  def skipped?
715
720
  defined?(@skip) and @skip
716
721
  end
@@ -726,7 +731,7 @@ module MiniTest
726
731
  end
727
732
 
728
733
  class Unit # :nodoc:
729
- VERSION = "4.7.1" # :nodoc:
734
+ VERSION = "4.7.2" # :nodoc:
730
735
 
731
736
  attr_accessor :report, :failures, :errors, :skips # :nodoc:
732
737
  attr_accessor :assertion_count # :nodoc:
@@ -300,6 +300,18 @@ class TestMiniTestStub < MiniTest::Unit::TestCase
300
300
  end
301
301
  end
302
302
 
303
+ def test_stub_module
304
+ @assertion_count += 1
305
+
306
+ t0 = Time.now
307
+
308
+ Kernel.stub :sleep, nil do
309
+ @tc.assert_nil sleep(10)
310
+ end
311
+
312
+ @tc.assert_operator Time.now - t0, :<=, 1
313
+ end
314
+
303
315
  def test_stub_value
304
316
  assert_stub 42
305
317
  end
@@ -199,16 +199,16 @@ describe MiniTest::Spec do
199
199
 
200
200
  24.wont_be_close_to(42).must_equal false
201
201
 
202
- assert_triggered "Expected |42 - 42.0| (0.0) to not be < 0.001." do
202
+ assert_triggered "Expected |42 - 42.0| (0.0) to not be <= 0.001." do
203
203
  (6 * 7.0).wont_be_close_to 42
204
204
  end
205
205
 
206
206
  x = maglev? ? "1.0000000000000001e-05" : "1.0e-05"
207
- assert_triggered "Expected |42 - 42.0| (0.0) to not be < #{x}." do
207
+ assert_triggered "Expected |42 - 42.0| (0.0) to not be <= #{x}." do
208
208
  (6 * 7.0).wont_be_close_to 42, 0.00001
209
209
  end
210
210
 
211
- assert_triggered "msg.\nExpected |42 - 42.0| (0.0) to not be < #{x}." do
211
+ assert_triggered "msg.\nExpected |42 - 42.0| (0.0) to not be <= #{x}." do
212
212
  (6 * 7.0).wont_be_close_to 42, 0.00001, "msg"
213
213
  end
214
214
  end
@@ -219,16 +219,16 @@ describe MiniTest::Spec do
219
219
  24.wont_be_within_epsilon(42).must_equal false
220
220
 
221
221
  x = maglev? ? "0.042000000000000003" : "0.042"
222
- assert_triggered "Expected |42 - 42.0| (0.0) to not be < #{x}." do
222
+ assert_triggered "Expected |42 - 42.0| (0.0) to not be <= #{x}." do
223
223
  (6 * 7.0).wont_be_within_epsilon 42
224
224
  end
225
225
 
226
226
  x = maglev? ? "0.00042000000000000002" : "0.00042"
227
- assert_triggered "Expected |42 - 42.0| (0.0) to not be < #{x}." do
227
+ assert_triggered "Expected |42 - 42.0| (0.0) to not be <= #{x}." do
228
228
  (6 * 7.0).wont_be_within_epsilon 42, 0.00001
229
229
  end
230
230
 
231
- assert_triggered "msg.\nExpected |42 - 42.0| (0.0) to not be < #{x}." do
231
+ assert_triggered "msg.\nExpected |42 - 42.0| (0.0) to not be <= #{x}." do
232
232
  (6 * 7.0).wont_be_within_epsilon 42, 0.00001, "msg"
233
233
  end
234
234
  end
@@ -238,16 +238,16 @@ describe MiniTest::Spec do
238
238
 
239
239
  (6.0 * 7).must_be_close_to(42.0).must_equal true
240
240
 
241
- assert_triggered "Expected |0.0 - 0.01| (0.01) to be < 0.001." do
241
+ assert_triggered "Expected |0.0 - 0.01| (0.01) to be <= 0.001." do
242
242
  (1.0 / 100).must_be_close_to 0.0
243
243
  end
244
244
 
245
245
  x = maglev? ? "9.9999999999999995e-07" : "1.0e-06"
246
- assert_triggered "Expected |0.0 - 0.001| (0.001) to be < #{x}." do
246
+ assert_triggered "Expected |0.0 - 0.001| (0.001) to be <= #{x}." do
247
247
  (1.0 / 1000).must_be_close_to 0.0, 0.000001
248
248
  end
249
249
 
250
- assert_triggered "msg.\nExpected |0.0 - 0.001| (0.001) to be < #{x}." do
250
+ assert_triggered "msg.\nExpected |0.0 - 0.001| (0.001) to be <= #{x}." do
251
251
  (1.0 / 1000).must_be_close_to 0.0, 0.000001, "msg"
252
252
  end
253
253
  end
@@ -257,15 +257,15 @@ describe MiniTest::Spec do
257
257
 
258
258
  (6.0 * 7).must_be_within_epsilon(42.0).must_equal true
259
259
 
260
- assert_triggered "Expected |0.0 - 0.01| (0.01) to be < 0.0." do
260
+ assert_triggered "Expected |0.0 - 0.01| (0.01) to be <= 0.0." do
261
261
  (1.0 / 100).must_be_within_epsilon 0.0
262
262
  end
263
263
 
264
- assert_triggered "Expected |0.0 - 0.001| (0.001) to be < 0.0." do
264
+ assert_triggered "Expected |0.0 - 0.001| (0.001) to be <= 0.0." do
265
265
  (1.0 / 1000).must_be_within_epsilon 0.0, 0.000001
266
266
  end
267
267
 
268
- assert_triggered "msg.\nExpected |0.0 - 0.001| (0.001) to be < 0.0." do
268
+ assert_triggered "msg.\nExpected |0.0 - 0.001| (0.001) to be <= 0.0." do
269
269
  (1.0 / 1000).must_be_within_epsilon 0.0, 0.000001, "msg"
270
270
  end
271
271
  end
@@ -921,9 +921,17 @@ class TestMiniTestUnitTestCase < MiniTest::Unit::TestCase
921
921
  @tc.assert_in_delta 0.0, 1.0 / 1000, 0.1
922
922
  end
923
923
 
924
+ def test_delta_consistency
925
+ @tc.assert_in_delta 0, 1, 1
926
+
927
+ util_assert_triggered "Expected |0 - 1| (1) to not be <= 1." do
928
+ @tc.refute_in_delta 0, 1, 1
929
+ end
930
+ end
931
+
924
932
  def test_assert_in_delta_triggered
925
- x = maglev? ? "9.9999999999999995e-07" : "1.0e-06"
926
- util_assert_triggered "Expected |0.0 - 0.001| (0.001) to be < #{x}." do
933
+ x = maglev? ? "9.999999xxxe-07" : "1.0e-06"
934
+ util_assert_triggered "Expected |0.0 - 0.001| (0.001) to be <= #{x}." do
927
935
  @tc.assert_in_delta 0.0, 1.0 / 1000, 0.000001
928
936
  end
929
937
  end
@@ -945,16 +953,25 @@ class TestMiniTestUnitTestCase < MiniTest::Unit::TestCase
945
953
  @tc.assert_in_epsilon(-10000, -9991)
946
954
  end
947
955
 
956
+ def test_epsilon_consistency
957
+ @tc.assert_in_epsilon 1.0, 1.001
958
+
959
+ msg = "Expected |1.0 - 1.001| (0.000999xxx) to not be <= 0.001."
960
+ util_assert_triggered msg do
961
+ @tc.refute_in_epsilon 1.0, 1.001
962
+ end
963
+ end
964
+
948
965
  def test_assert_in_epsilon_triggered
949
- util_assert_triggered 'Expected |10000 - 9990| (10) to be < 9.99.' do
966
+ util_assert_triggered 'Expected |10000 - 9990| (10) to be <= 9.99.' do
950
967
  @tc.assert_in_epsilon 10000, 9990
951
968
  end
952
969
  end
953
970
 
954
971
  def test_assert_in_epsilon_triggered_negative_case
955
- x = (RUBY18 and not maglev?) ? "0.1" : "0.10000000000000009"
956
- y = maglev? ? "0.10000000000000001" : "0.1"
957
- util_assert_triggered "Expected |-1.1 - -1| (#{x}) to be < #{y}." do
972
+ x = (RUBY18 and not maglev?) ? "0.1" : "0.100000xxx"
973
+ y = maglev? ? "0.100000xxx" : "0.1"
974
+ util_assert_triggered "Expected |-1.1 - -1| (#{x}) to be <= #{y}." do
958
975
  @tc.assert_in_epsilon(-1.1, -1, 0.1)
959
976
  end
960
977
  end
@@ -1500,19 +1517,19 @@ class TestMiniTestUnitTestCase < MiniTest::Unit::TestCase
1500
1517
  end
1501
1518
 
1502
1519
  def test_refute_in_delta_triggered
1503
- x = maglev? ? "0.10000000000000001" : "0.1"
1504
- util_assert_triggered "Expected |0.0 - 0.001| (0.001) to not be < #{x}." do
1520
+ x = maglev? ? "0.100000xxx" : "0.1"
1521
+ util_assert_triggered "Expected |0.0 - 0.001| (0.001) to not be <= #{x}." do
1505
1522
  @tc.refute_in_delta 0.0, 1.0 / 1000, 0.1
1506
1523
  end
1507
1524
  end
1508
1525
 
1509
1526
  def test_refute_in_epsilon
1510
- @tc.refute_in_epsilon 10000, 9990
1527
+ @tc.refute_in_epsilon 10000, 9990-1
1511
1528
  end
1512
1529
 
1513
1530
  def test_refute_in_epsilon_triggered
1514
- util_assert_triggered 'Expected |10000 - 9991| (9) to not be < 10.0.' do
1515
- @tc.refute_in_epsilon 10000, 9991
1531
+ util_assert_triggered 'Expected |10000 - 9990| (10) to not be <= 10.0.' do
1532
+ @tc.refute_in_epsilon 10000, 9990
1516
1533
  fail
1517
1534
  end
1518
1535
  end
@@ -1711,6 +1728,7 @@ class TestMiniTestUnitTestCase < MiniTest::Unit::TestCase
1711
1728
 
1712
1729
  msg = e.message.sub(/(---Backtrace---).*/m, '\1')
1713
1730
  msg.gsub!(/\(oid=[-0-9]+\)/, '(oid=N)')
1731
+ msg.gsub!(/(\d\.\d{6})\d+/, '\1xxx') # normalize: ruby version, impl, platform
1714
1732
 
1715
1733
  assert_equal expected, msg
1716
1734
  end
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: 33
4
+ hash: 39
5
5
  prerelease:
6
6
  segments:
7
7
  - 4
8
8
  - 7
9
- - 1
10
- version: 4.7.1
9
+ - 2
10
+ version: 4.7.2
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-04-10 00:00:00 Z
39
+ date: 2013-04-18 00:00:00 Z
40
40
  dependencies:
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rdoc
@@ -61,11 +61,11 @@ dependencies:
61
61
  requirements:
62
62
  - - ~>
63
63
  - !ruby/object:Gem::Version
64
- hash: 13
64
+ hash: 11
65
65
  segments:
66
66
  - 3
67
- - 5
68
- version: "3.5"
67
+ - 6
68
+ version: "3.6"
69
69
  type: :development
70
70
  version_requirements: *id002
71
71
  description: |-
metadata.gz.sig CHANGED
Binary file