minitest 5.22.3 → 5.25.4
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.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +2 -2
- data/History.rdoc +95 -0
- data/Manifest.txt +2 -0
- data/README.rdoc +15 -13
- data/Rakefile +6 -0
- data/lib/hoe/minitest.rb +2 -1
- data/lib/minitest/assertions.rb +64 -69
- data/lib/minitest/autorun.rb +0 -7
- data/lib/minitest/benchmark.rb +6 -9
- data/lib/minitest/compress.rb +10 -10
- data/lib/minitest/error_on_warning.rb +11 -0
- data/lib/minitest/manual_plugins.rb +16 -0
- data/lib/minitest/mock.rb +35 -17
- data/lib/minitest/parallel.rb +5 -5
- data/lib/minitest/pride_plugin.rb +10 -14
- data/lib/minitest/spec.rb +13 -12
- data/lib/minitest/test.rb +10 -22
- data/lib/minitest/test_task.rb +17 -11
- data/lib/minitest.rb +206 -136
- data/test/minitest/metametameta.rb +18 -10
- data/test/minitest/test_minitest_assertions.rb +133 -134
- data/test/minitest/test_minitest_benchmark.rb +1 -1
- data/test/minitest/test_minitest_mock.rb +150 -78
- data/test/minitest/test_minitest_reporter.rb +18 -22
- data/test/minitest/test_minitest_spec.rb +73 -56
- data/test/minitest/test_minitest_test.rb +84 -103
- data/test/minitest/test_minitest_test_task.rb +18 -9
- data.tar.gz.sig +0 -0
- metadata +5 -3
- metadata.gz.sig +0 -0
| @@ -10,8 +10,9 @@ end | |
| 10 10 |  | 
| 11 11 | 
             
            class TestMinitestMock < Minitest::Test
         | 
| 12 12 | 
             
              def setup
         | 
| 13 | 
            -
                @mock = Minitest::Mock.new | 
| 14 | 
            -
             | 
| 13 | 
            +
                @mock = Minitest::Mock.new
         | 
| 14 | 
            +
                  .expect(:foo, nil)
         | 
| 15 | 
            +
                  .expect(:meaning_of_life, 42)
         | 
| 15 16 | 
             
              end
         | 
| 16 17 |  | 
| 17 18 | 
             
              def test_create_stub_method
         | 
| @@ -25,7 +26,7 @@ class TestMinitestMock < Minitest::Test | |
| 25 26 | 
             
              def test_blow_up_if_not_called
         | 
| 26 27 | 
             
                @mock.foo
         | 
| 27 28 |  | 
| 28 | 
            -
                util_verify_bad " | 
| 29 | 
            +
                util_verify_bad "Expected meaning_of_life() => 42"
         | 
| 29 30 | 
             
              end
         | 
| 30 31 |  | 
| 31 32 | 
             
              def test_not_blow_up_if_everything_called
         | 
| @@ -36,22 +37,22 @@ class TestMinitestMock < Minitest::Test | |
| 36 37 | 
             
              end
         | 
| 37 38 |  | 
| 38 39 | 
             
              def test_allow_expectations_to_be_added_after_creation
         | 
| 39 | 
            -
                @mock.expect | 
| 40 | 
            +
                @mock.expect :bar, true
         | 
| 40 41 | 
             
                assert @mock.bar
         | 
| 41 42 | 
             
              end
         | 
| 42 43 |  | 
| 43 44 | 
             
              def test_not_verify_if_new_expected_method_is_not_called
         | 
| 44 45 | 
             
                @mock.foo
         | 
| 45 46 | 
             
                @mock.meaning_of_life
         | 
| 46 | 
            -
                @mock.expect | 
| 47 | 
            +
                @mock.expect :bar, true
         | 
| 47 48 |  | 
| 48 | 
            -
                util_verify_bad " | 
| 49 | 
            +
                util_verify_bad "Expected bar() => true"
         | 
| 49 50 | 
             
              end
         | 
| 50 51 |  | 
| 51 52 | 
             
              def test_blow_up_on_wrong_number_of_arguments
         | 
| 52 53 | 
             
                @mock.foo
         | 
| 53 54 | 
             
                @mock.meaning_of_life
         | 
| 54 | 
            -
                @mock.expect | 
| 55 | 
            +
                @mock.expect :sum, 3, [1, 2]
         | 
| 55 56 |  | 
| 56 57 | 
             
                e = assert_raises ArgumentError do
         | 
| 57 58 | 
             
                  @mock.sum
         | 
| @@ -63,7 +64,7 @@ class TestMinitestMock < Minitest::Test | |
| 63 64 | 
             
              def test_return_mock_does_not_raise
         | 
| 64 65 | 
             
                retval = Minitest::Mock.new
         | 
| 65 66 | 
             
                mock = Minitest::Mock.new
         | 
| 66 | 
            -
                mock.expect | 
| 67 | 
            +
                mock.expect :foo, retval
         | 
| 67 68 | 
             
                mock.foo
         | 
| 68 69 |  | 
| 69 70 | 
             
                assert_mock mock
         | 
| @@ -72,8 +73,8 @@ class TestMinitestMock < Minitest::Test | |
| 72 73 | 
             
              def test_mock_args_does_not_raise
         | 
| 73 74 | 
             
                arg = Minitest::Mock.new
         | 
| 74 75 | 
             
                mock = Minitest::Mock.new
         | 
| 75 | 
            -
                mock.expect | 
| 76 | 
            -
                mock.foo | 
| 76 | 
            +
                mock.expect :foo, nil, [arg]
         | 
| 77 | 
            +
                mock.foo arg
         | 
| 77 78 |  | 
| 78 79 | 
             
                assert_mock mock
         | 
| 79 80 | 
             
              end
         | 
| @@ -113,8 +114,6 @@ class TestMinitestMock < Minitest::Test | |
| 113 114 | 
             
              end
         | 
| 114 115 |  | 
| 115 116 | 
             
              def test_expectations_can_be_satisfied_via_public_send
         | 
| 116 | 
            -
                skip "Doesn't run on 1.8" if RUBY_VERSION < "1.9"
         | 
| 117 | 
            -
             | 
| 118 117 | 
             
                @mock.public_send :foo
         | 
| 119 118 | 
             
                @mock.public_send :meaning_of_life
         | 
| 120 119 |  | 
| @@ -124,10 +123,10 @@ class TestMinitestMock < Minitest::Test | |
| 124 123 | 
             
              def test_blow_up_on_wrong_arguments
         | 
| 125 124 | 
             
                @mock.foo
         | 
| 126 125 | 
             
                @mock.meaning_of_life
         | 
| 127 | 
            -
                @mock.expect | 
| 126 | 
            +
                @mock.expect :sum, 3, [1, 2]
         | 
| 128 127 |  | 
| 129 128 | 
             
                e = assert_raises MockExpectationError do
         | 
| 130 | 
            -
                  @mock.sum | 
| 129 | 
            +
                  @mock.sum 2, 4
         | 
| 131 130 | 
             
                end
         | 
| 132 131 |  | 
| 133 132 | 
             
                exp = "mocked method :sum called with unexpected arguments [2, 4]"
         | 
| @@ -163,8 +162,8 @@ class TestMinitestMock < Minitest::Test | |
| 163 162 | 
             
                a = Minitest::Mock.new
         | 
| 164 163 | 
             
                b = Minitest::Mock.new
         | 
| 165 164 |  | 
| 166 | 
            -
                a.expect | 
| 167 | 
            -
                b.expect | 
| 165 | 
            +
                a.expect :foo, :a
         | 
| 166 | 
            +
                b.expect :foo, :b
         | 
| 168 167 |  | 
| 169 168 | 
             
                assert_equal :a, a.foo
         | 
| 170 169 | 
             
                assert_equal :b, b.foo
         | 
| @@ -172,7 +171,7 @@ class TestMinitestMock < Minitest::Test | |
| 172 171 |  | 
| 173 172 | 
             
              def test_do_not_create_stub_method_on_new_mocks
         | 
| 174 173 | 
             
                a = Minitest::Mock.new
         | 
| 175 | 
            -
                a.expect | 
| 174 | 
            +
                a.expect :foo, :a
         | 
| 176 175 |  | 
| 177 176 | 
             
                assert !Minitest::Mock.new.respond_to?(:foo)
         | 
| 178 177 | 
             
              end
         | 
| @@ -181,10 +180,77 @@ class TestMinitestMock < Minitest::Test | |
| 181 180 | 
             
                @mock.expect :kind_of?, true, [String]
         | 
| 182 181 | 
             
                @mock.expect :==, true, [1]
         | 
| 183 182 |  | 
| 184 | 
            -
                assert @mock.kind_of?(String), "didn't mock :kind_of | 
| 183 | 
            +
                assert @mock.kind_of?(String), "didn't mock :kind_of?"
         | 
| 185 184 | 
             
                assert @mock == 1, "didn't mock :=="
         | 
| 186 185 | 
             
              end
         | 
| 187 186 |  | 
| 187 | 
            +
              def test_assert_mock__pass
         | 
| 188 | 
            +
                mock = Minitest::Mock.new
         | 
| 189 | 
            +
                mock.expect :loose_expectation, true, [Integer]
         | 
| 190 | 
            +
                mock.loose_expectation 1
         | 
| 191 | 
            +
             | 
| 192 | 
            +
                result = assert_mock mock
         | 
| 193 | 
            +
             | 
| 194 | 
            +
                assert_equal true, result
         | 
| 195 | 
            +
              end
         | 
| 196 | 
            +
             | 
| 197 | 
            +
              def assert_bad_mock klass, msg
         | 
| 198 | 
            +
                mock = Minitest::Mock.new
         | 
| 199 | 
            +
                mock.expect :foo, nil, [:bar]
         | 
| 200 | 
            +
                mock.expect :foo, nil, [:baz]
         | 
| 201 | 
            +
             | 
| 202 | 
            +
                mock.foo :bar
         | 
| 203 | 
            +
             | 
| 204 | 
            +
                e = assert_raises klass do
         | 
| 205 | 
            +
                  yield mock
         | 
| 206 | 
            +
                end
         | 
| 207 | 
            +
             | 
| 208 | 
            +
                assert_equal msg, e.message
         | 
| 209 | 
            +
              end
         | 
| 210 | 
            +
             | 
| 211 | 
            +
              def test_verify__error
         | 
| 212 | 
            +
                exp = "Expected foo(:baz) => nil, got [foo(:bar) => nil]"
         | 
| 213 | 
            +
                assert_bad_mock MockExpectationError, exp do |mock|
         | 
| 214 | 
            +
                  mock.verify
         | 
| 215 | 
            +
                end
         | 
| 216 | 
            +
              end
         | 
| 217 | 
            +
             | 
| 218 | 
            +
              def test_assert_mock__fail
         | 
| 219 | 
            +
                exp = "Expected foo(:baz) => nil, got [foo(:bar) => nil]."
         | 
| 220 | 
            +
                assert_bad_mock Minitest::Assertion, exp do |mock|
         | 
| 221 | 
            +
                  assert_mock mock
         | 
| 222 | 
            +
                end
         | 
| 223 | 
            +
              end
         | 
| 224 | 
            +
             | 
| 225 | 
            +
              def test_assert_mock__fail_msg
         | 
| 226 | 
            +
                exp = "BLAH.\nExpected foo(:baz) => nil, got [foo(:bar) => nil]."
         | 
| 227 | 
            +
                assert_bad_mock Minitest::Assertion, exp do |mock|
         | 
| 228 | 
            +
                  assert_mock mock, "BLAH"
         | 
| 229 | 
            +
                end
         | 
| 230 | 
            +
              end
         | 
| 231 | 
            +
             | 
| 232 | 
            +
              def test_assert_mock__fail_exp
         | 
| 233 | 
            +
                exp = "Expected foo(:baz) => nil, got [foo(:bar) => nil]."
         | 
| 234 | 
            +
                assert_bad_mock Minitest::Assertion, exp do |mock|
         | 
| 235 | 
            +
                  describe "X" do
         | 
| 236 | 
            +
                    it "y" do
         | 
| 237 | 
            +
                      _(mock).must_verify
         | 
| 238 | 
            +
                    end
         | 
| 239 | 
            +
                  end.new(:blah).send(:test_0001_y)
         | 
| 240 | 
            +
                end
         | 
| 241 | 
            +
              end
         | 
| 242 | 
            +
             | 
| 243 | 
            +
              def test_assert_mock__fail_exp_msg
         | 
| 244 | 
            +
                exp = "BLAH.\nExpected foo(:baz) => nil, got [foo(:bar) => nil]."
         | 
| 245 | 
            +
                assert_bad_mock Minitest::Assertion, exp do |mock|
         | 
| 246 | 
            +
                  describe "X" do
         | 
| 247 | 
            +
                    it "y" do
         | 
| 248 | 
            +
                      _(mock).must_verify "BLAH"
         | 
| 249 | 
            +
                    end
         | 
| 250 | 
            +
                  end.new(:blah).send(:test_0001_y)
         | 
| 251 | 
            +
                end
         | 
| 252 | 
            +
              end
         | 
| 253 | 
            +
             | 
| 188 254 | 
             
              def test_verify_allows_called_args_to_be_loosely_specified
         | 
| 189 255 | 
             
                mock = Minitest::Mock.new
         | 
| 190 256 | 
             
                mock.expect :loose_expectation, true, [Integer]
         | 
| @@ -239,7 +305,7 @@ class TestMinitestMock < Minitest::Test | |
| 239 305 |  | 
| 240 306 | 
             
                e = assert_raises(MockExpectationError) { mock.verify }
         | 
| 241 307 |  | 
| 242 | 
            -
                exp = " | 
| 308 | 
            +
                exp = "Expected foo(:baz) => nil, got [foo(:bar) => nil]"
         | 
| 243 309 |  | 
| 244 310 | 
             
                assert_equal exp, e.message
         | 
| 245 311 | 
             
              end
         | 
| @@ -253,7 +319,7 @@ class TestMinitestMock < Minitest::Test | |
| 253 319 |  | 
| 254 320 | 
             
                e = assert_raises(MockExpectationError) { mock.verify }
         | 
| 255 321 |  | 
| 256 | 
            -
                exp = " | 
| 322 | 
            +
                exp = "Expected foo(:bar) => nil, got [foo(:bar) => nil]"
         | 
| 257 323 |  | 
| 258 324 | 
             
                assert_equal exp, e.message
         | 
| 259 325 | 
             
              end
         | 
| @@ -277,9 +343,10 @@ class TestMinitestMock < Minitest::Test | |
| 277 343 |  | 
| 278 344 | 
             
                e = assert_raises(MockExpectationError) { mock.verify }
         | 
| 279 345 |  | 
| 280 | 
            -
                exp = " | 
| 346 | 
            +
                exp = "Expected foo(%p) => nil, got [foo(%p) => nil]" \
         | 
| 347 | 
            +
                  % [{ :kw => false }, { :kw => true  }]
         | 
| 281 348 |  | 
| 282 | 
            -
                assert_equal exp, e.message
         | 
| 349 | 
            +
                assert_equal exp.delete("{}"), e.message
         | 
| 283 350 | 
             
              end
         | 
| 284 351 |  | 
| 285 352 | 
             
              def test_verify_passes_when_mock_block_returns_true
         | 
| @@ -318,7 +385,7 @@ class TestMinitestMock < Minitest::Test | |
| 318 385 | 
             
                  k1 == arg1 && k2 == arg2 && k3 == arg3
         | 
| 319 386 | 
             
                end
         | 
| 320 387 |  | 
| 321 | 
            -
                mock.foo | 
| 388 | 
            +
                mock.foo k1: arg1, k2: arg2, k3: arg3
         | 
| 322 389 |  | 
| 323 390 | 
             
                assert_mock mock
         | 
| 324 391 | 
             
              end
         | 
| @@ -331,7 +398,7 @@ class TestMinitestMock < Minitest::Test | |
| 331 398 | 
             
                end
         | 
| 332 399 |  | 
| 333 400 | 
             
                e = assert_raises ArgumentError do
         | 
| 334 | 
            -
                  mock.foo | 
| 401 | 
            +
                  mock.foo k1: arg1, k2: arg2
         | 
| 335 402 | 
             
                end
         | 
| 336 403 |  | 
| 337 404 | 
             
                # basically testing ruby ... need ? for ruby < 2.7 :(
         | 
| @@ -346,7 +413,7 @@ class TestMinitestMock < Minitest::Test | |
| 346 413 | 
             
                end
         | 
| 347 414 |  | 
| 348 415 | 
             
                e = assert_raises ArgumentError do
         | 
| 349 | 
            -
                  mock.foo | 
| 416 | 
            +
                  mock.foo k1: arg1, k2: arg2, k3: arg3
         | 
| 350 417 | 
             
                end
         | 
| 351 418 |  | 
| 352 419 | 
             
                # basically testing ruby ... need ? for ruby < 2.7 :(
         | 
| @@ -361,10 +428,12 @@ class TestMinitestMock < Minitest::Test | |
| 361 428 | 
             
                end
         | 
| 362 429 |  | 
| 363 430 | 
             
                e = assert_raises MockExpectationError do
         | 
| 364 | 
            -
                  mock.foo | 
| 431 | 
            +
                  mock.foo k1: arg1, k2: arg2, k3: :BAD!
         | 
| 365 432 | 
             
                end
         | 
| 366 433 |  | 
| 367 | 
            -
                exp = "mocked method :foo failed block w/ []  | 
| 434 | 
            +
                exp = "mocked method :foo failed block w/ [] %p" \
         | 
| 435 | 
            +
                  % [{ :k1 => :bar, :k2 => [1, 2, 3], :k3 => :BAD! }]
         | 
| 436 | 
            +
             | 
| 368 437 | 
             
                assert_equal exp, e.message
         | 
| 369 438 | 
             
              end
         | 
| 370 439 |  | 
| @@ -373,7 +442,7 @@ class TestMinitestMock < Minitest::Test | |
| 373 442 | 
             
                mock = Minitest::Mock.new
         | 
| 374 443 | 
             
                mock.expect :foo, nil, k1: arg1, k2: arg2, k3: arg3
         | 
| 375 444 |  | 
| 376 | 
            -
                mock.foo | 
| 445 | 
            +
                mock.foo k1: arg1, k2: arg2, k3: arg3
         | 
| 377 446 |  | 
| 378 447 | 
             
                assert_mock mock
         | 
| 379 448 | 
             
              end
         | 
| @@ -397,10 +466,10 @@ class TestMinitestMock < Minitest::Test | |
| 397 466 | 
             
              def test_mock_block_is_passed_keyword_args__args__old_style_bad
         | 
| 398 467 | 
             
                arg1, arg2, arg3 = :bar, [1, 2, 3], { :a => "a" }
         | 
| 399 468 | 
             
                mock = Minitest::Mock.new
         | 
| 400 | 
            -
                mock.expect :foo, nil, [{k1: arg1, k2: arg2, k3: arg3}]
         | 
| 469 | 
            +
                mock.expect :foo, nil, [{ k1: arg1, k2: arg2, k3: arg3 }]
         | 
| 401 470 |  | 
| 402 471 | 
             
                e = assert_raises ArgumentError do
         | 
| 403 | 
            -
                  mock.foo | 
| 472 | 
            +
                  mock.foo k1: arg1, k2: arg2, k3: arg3
         | 
| 404 473 | 
             
                end
         | 
| 405 474 |  | 
| 406 475 | 
             
                assert_equal "mocked method :foo expects 1 arguments, got []", e.message
         | 
| @@ -410,9 +479,9 @@ class TestMinitestMock < Minitest::Test | |
| 410 479 | 
             
                with_kwargs_env do
         | 
| 411 480 | 
             
                  arg1, arg2, arg3 = :bar, [1, 2, 3], { :a => "a" }
         | 
| 412 481 | 
             
                  mock = Minitest::Mock.new
         | 
| 413 | 
            -
                  mock.expect :foo, nil, [{k1: arg1, k2: arg2, k3: arg3}]
         | 
| 482 | 
            +
                  mock.expect :foo, nil, [{ k1: arg1, k2: arg2, k3: arg3 }]
         | 
| 414 483 |  | 
| 415 | 
            -
                  mock.foo | 
| 484 | 
            +
                  mock.foo k1: arg1, k2: arg2, k3: arg3
         | 
| 416 485 |  | 
| 417 486 | 
             
                  assert_mock mock
         | 
| 418 487 | 
             
                end
         | 
| @@ -423,10 +492,12 @@ class TestMinitestMock < Minitest::Test | |
| 423 492 | 
             
                  arg1, arg2, arg3 = :bar, [1, 2, 3], { :a => "a" }
         | 
| 424 493 | 
             
                  mock = Minitest::Mock.new
         | 
| 425 494 |  | 
| 426 | 
            -
                   | 
| 495 | 
            +
                  assert_deprecation(/Using MT_KWARGS_HAC. yet passing kwargs/) do
         | 
| 427 496 | 
             
                    mock.expect :foo, nil, [{}], k1: arg1, k2: arg2, k3: arg3
         | 
| 428 497 | 
             
                  end
         | 
| 429 498 |  | 
| 499 | 
            +
                  skip "-Werror" if error_on_warn? # mock above raised, so this is dead
         | 
| 500 | 
            +
             | 
| 430 501 | 
             
                  mock.foo({}, k1: arg1, k2: arg2, k3: arg3)
         | 
| 431 502 |  | 
| 432 503 | 
             
                  assert_mock mock
         | 
| @@ -439,10 +510,10 @@ class TestMinitestMock < Minitest::Test | |
| 439 510 | 
             
                mock.expect :foo, nil, k1: arg1, k2: arg2, k3: arg3
         | 
| 440 511 |  | 
| 441 512 | 
             
                e = assert_raises ArgumentError do
         | 
| 442 | 
            -
                  mock.foo | 
| 513 | 
            +
                  mock.foo k1: arg1, k2: arg2
         | 
| 443 514 | 
             
                end
         | 
| 444 515 |  | 
| 445 | 
            -
                assert_equal "mocked method :foo expects 3 keyword arguments, got %p" % {k1: arg1, k2: arg2}, e.message
         | 
| 516 | 
            +
                assert_equal "mocked method :foo expects 3 keyword arguments, got %p" % { k1: arg1, k2: arg2 }, e.message
         | 
| 446 517 | 
             
              end
         | 
| 447 518 |  | 
| 448 519 | 
             
              def test_mock_block_is_passed_keyword_args__args_bad_extra
         | 
| @@ -451,10 +522,10 @@ class TestMinitestMock < Minitest::Test | |
| 451 522 | 
             
                mock.expect :foo, nil, k1: arg1, k2: arg2
         | 
| 452 523 |  | 
| 453 524 | 
             
                e = assert_raises ArgumentError do
         | 
| 454 | 
            -
                  mock.foo | 
| 525 | 
            +
                  mock.foo k1: arg1, k2: arg2, k3: arg3
         | 
| 455 526 | 
             
                end
         | 
| 456 527 |  | 
| 457 | 
            -
                assert_equal "mocked method :foo expects 2 keyword arguments, got %p" % {k1: arg1, k2: arg2, k3: arg3}, e.message
         | 
| 528 | 
            +
                assert_equal "mocked method :foo expects 2 keyword arguments, got %p" % { k1: arg1, k2: arg2, k3: arg3 }, e.message
         | 
| 458 529 | 
             
              end
         | 
| 459 530 |  | 
| 460 531 | 
             
              def test_mock_block_is_passed_keyword_args__args_bad_key
         | 
| @@ -463,7 +534,7 @@ class TestMinitestMock < Minitest::Test | |
| 463 534 | 
             
                mock.expect :foo, nil, k1: arg1, k2: arg2, k3: arg3
         | 
| 464 535 |  | 
| 465 536 | 
             
                e = assert_raises MockExpectationError do
         | 
| 466 | 
            -
                  mock.foo | 
| 537 | 
            +
                  mock.foo k1: arg1, k2: arg2, BAD: arg3
         | 
| 467 538 | 
             
                end
         | 
| 468 539 |  | 
| 469 540 | 
             
                assert_includes e.message, "unexpected keywords [:k1, :k2, :k3]"
         | 
| @@ -476,18 +547,18 @@ class TestMinitestMock < Minitest::Test | |
| 476 547 | 
             
                mock.expect :foo, nil, k1: arg1, k2: arg2, k3: arg3
         | 
| 477 548 |  | 
| 478 549 | 
             
                e = assert_raises MockExpectationError do
         | 
| 479 | 
            -
                  mock.foo | 
| 550 | 
            +
                  mock.foo k1: arg1, k2: :BAD!, k3: arg3
         | 
| 480 551 | 
             
                end
         | 
| 481 552 |  | 
| 482 | 
            -
                 | 
| 553 | 
            +
                bad = { :k2 => :BAD! }.inspect.delete "{}"
         | 
| 554 | 
            +
                assert_match(/unexpected keyword arguments.* vs .*#{bad}/, e.message)
         | 
| 483 555 | 
             
              end
         | 
| 484 556 |  | 
| 485 557 | 
             
              def test_mock_block_is_passed_function_block
         | 
| 486 558 | 
             
                mock = Minitest::Mock.new
         | 
| 487 559 | 
             
                block = proc { "bar" }
         | 
| 488 560 | 
             
                mock.expect :foo, nil do |arg, &blk|
         | 
| 489 | 
            -
                  arg == "foo" &&
         | 
| 490 | 
            -
                  blk == block
         | 
| 561 | 
            +
                  arg == "foo" && blk == block
         | 
| 491 562 | 
             
                end
         | 
| 492 563 | 
             
                mock.foo "foo", &block
         | 
| 493 564 | 
             
                assert_mock mock
         | 
| @@ -495,8 +566,8 @@ class TestMinitestMock < Minitest::Test | |
| 495 566 |  | 
| 496 567 | 
             
              def test_mock_forward_keyword_arguments
         | 
| 497 568 | 
             
                mock = Minitest::Mock.new
         | 
| 498 | 
            -
                mock.expect(:foo, nil) { |bar:| bar ==  | 
| 499 | 
            -
                mock.foo | 
| 569 | 
            +
                mock.expect(:foo, nil) { |bar:| bar == "bar" }
         | 
| 570 | 
            +
                mock.foo bar: "bar"
         | 
| 500 571 | 
             
                assert_mock mock
         | 
| 501 572 | 
             
              end
         | 
| 502 573 |  | 
| @@ -515,7 +586,7 @@ class TestMinitestMock < Minitest::Test | |
| 515 586 | 
             
              def test_mock_block_raises_if_args_passed
         | 
| 516 587 | 
             
                mock = Minitest::Mock.new
         | 
| 517 588 |  | 
| 518 | 
            -
                e = assert_raises | 
| 589 | 
            +
                e = assert_raises ArgumentError do
         | 
| 519 590 | 
             
                  mock.expect :foo, nil, [:a, :b, :c] do
         | 
| 520 591 | 
             
                    true
         | 
| 521 592 | 
             
                  end
         | 
| @@ -529,8 +600,8 @@ class TestMinitestMock < Minitest::Test | |
| 529 600 | 
             
              def test_mock_block_raises_if_kwargs_passed
         | 
| 530 601 | 
             
                mock = Minitest::Mock.new
         | 
| 531 602 |  | 
| 532 | 
            -
                e = assert_raises | 
| 533 | 
            -
                  mock.expect :foo, nil, kwargs:1 do
         | 
| 603 | 
            +
                e = assert_raises ArgumentError do
         | 
| 604 | 
            +
                  mock.expect :foo, nil, kwargs: 1 do
         | 
| 534 605 | 
             
                    true
         | 
| 535 606 | 
             
                  end
         | 
| 536 607 | 
             
                end
         | 
| @@ -542,7 +613,7 @@ class TestMinitestMock < Minitest::Test | |
| 542 613 |  | 
| 543 614 | 
             
              def test_mock_returns_retval_when_called_with_block
         | 
| 544 615 | 
             
                mock = Minitest::Mock.new
         | 
| 545 | 
            -
                mock.expect | 
| 616 | 
            +
                mock.expect :foo, 32 do
         | 
| 546 617 | 
             
                  true
         | 
| 547 618 | 
             
                end
         | 
| 548 619 |  | 
| @@ -561,7 +632,7 @@ class TestMinitestMock < Minitest::Test | |
| 561 632 |  | 
| 562 633 | 
             
              def test_mock_called_via_send
         | 
| 563 634 | 
             
                mock = Minitest::Mock.new
         | 
| 564 | 
            -
                mock.expect | 
| 635 | 
            +
                mock.expect :foo, true
         | 
| 565 636 |  | 
| 566 637 | 
             
                mock.send :foo
         | 
| 567 638 | 
             
                assert_mock mock
         | 
| @@ -569,7 +640,7 @@ class TestMinitestMock < Minitest::Test | |
| 569 640 |  | 
| 570 641 | 
             
              def test_mock_called_via___send__
         | 
| 571 642 | 
             
                mock = Minitest::Mock.new
         | 
| 572 | 
            -
                mock.expect | 
| 643 | 
            +
                mock.expect :foo, true
         | 
| 573 644 |  | 
| 574 645 | 
             
                mock.__send__ :foo
         | 
| 575 646 | 
             
                assert_mock mock
         | 
| @@ -577,9 +648,9 @@ class TestMinitestMock < Minitest::Test | |
| 577 648 |  | 
| 578 649 | 
             
              def test_mock_called_via_send_with_args
         | 
| 579 650 | 
             
                mock = Minitest::Mock.new
         | 
| 580 | 
            -
                mock.expect | 
| 651 | 
            +
                mock.expect :foo, true, [1, 2, 3]
         | 
| 581 652 |  | 
| 582 | 
            -
                mock.send | 
| 653 | 
            +
                mock.send :foo, 1, 2, 3
         | 
| 583 654 | 
             
                assert_mock mock
         | 
| 584 655 | 
             
              end
         | 
| 585 656 |  | 
| @@ -655,7 +726,7 @@ class TestMinitestStub < Minitest::Test | |
| 655 726 | 
             
                end
         | 
| 656 727 | 
             
              end
         | 
| 657 728 |  | 
| 658 | 
            -
              def  | 
| 729 | 
            +
              def test_stub_value__literal
         | 
| 659 730 | 
             
                assert_stub 42
         | 
| 660 731 | 
             
              end
         | 
| 661 732 |  | 
| @@ -686,7 +757,7 @@ class TestMinitestStub < Minitest::Test | |
| 686 757 | 
             
              end
         | 
| 687 758 |  | 
| 688 759 | 
             
              def test_stub_yield_self
         | 
| 689 | 
            -
                obj = "foo"
         | 
| 760 | 
            +
                obj = +"foo"
         | 
| 690 761 |  | 
| 691 762 | 
             
                val = obj.stub :to_s, "bar" do |s|
         | 
| 692 763 | 
             
                  s.to_s
         | 
| @@ -712,7 +783,7 @@ class TestMinitestStub < Minitest::Test | |
| 712 783 | 
             
                  end
         | 
| 713 784 | 
             
                end
         | 
| 714 785 |  | 
| 715 | 
            -
                val = dynamic.stub | 
| 786 | 
            +
                val = dynamic.stub :found, true do |s|
         | 
| 716 787 | 
             
                  s.found
         | 
| 717 788 | 
             
                end
         | 
| 718 789 |  | 
| @@ -727,14 +798,17 @@ class TestMinitestStub < Minitest::Test | |
| 727 798 | 
             
                  end
         | 
| 728 799 | 
             
                end
         | 
| 729 800 |  | 
| 730 | 
            -
                exp = jruby?  | 
| 731 | 
            -
             | 
| 801 | 
            +
                exp = if jruby? then
         | 
| 802 | 
            +
                        /Undefined method nope_nope_nope for '#{self.class}::Time'/
         | 
| 803 | 
            +
                      else
         | 
| 804 | 
            +
                        /undefined method [`']nope_nope_nope' for( class)? [`']#{self.class}::Time'/
         | 
| 805 | 
            +
                      end
         | 
| 732 806 | 
             
                assert_match exp, e.message
         | 
| 733 807 | 
             
              end
         | 
| 734 808 |  | 
| 735 809 | 
             
              def test_mock_with_yield
         | 
| 736 810 | 
             
                mock = Minitest::Mock.new
         | 
| 737 | 
            -
                mock.expect | 
| 811 | 
            +
                mock.expect :write, true do
         | 
| 738 812 | 
             
                  true
         | 
| 739 813 | 
             
                end
         | 
| 740 814 | 
             
                rs = nil
         | 
| @@ -751,7 +825,7 @@ class TestMinitestStub < Minitest::Test | |
| 751 825 | 
             
                mock = Minitest::Mock.new
         | 
| 752 826 | 
             
                rs = nil
         | 
| 753 827 |  | 
| 754 | 
            -
                File.stub :open, true, mock, kw:42 do
         | 
| 828 | 
            +
                File.stub :open, true, mock, kw: 42 do
         | 
| 755 829 | 
             
                  File.open "foo.txt", "r" do |f, kw:|
         | 
| 756 830 | 
             
                    rs = kw
         | 
| 757 831 | 
             
                  end
         | 
| @@ -760,8 +834,6 @@ class TestMinitestStub < Minitest::Test | |
| 760 834 | 
             
                @tc.assert_equal 42, rs
         | 
| 761 835 | 
             
              end
         | 
| 762 836 |  | 
| 763 | 
            -
              alias test_stub_value__old test_stub_value # TODO: remove/rename
         | 
| 764 | 
            -
             | 
| 765 837 | 
             
              ## Permutation Sets:
         | 
| 766 838 |  | 
| 767 839 | 
             
              # [:value, :lambda]
         | 
| @@ -816,7 +888,7 @@ class TestMinitestStub < Minitest::Test | |
| 816 888 | 
             
              # [:value,  :block_call, :args] =>  N/A
         | 
| 817 889 |  | 
| 818 890 | 
             
              class Bar
         | 
| 819 | 
            -
                def call
         | 
| 891 | 
            +
                def call &_ # to ignore unused block
         | 
| 820 892 | 
             
                  puts "hi"
         | 
| 821 893 | 
             
                end
         | 
| 822 894 | 
             
              end
         | 
| @@ -834,7 +906,7 @@ class TestMinitestStub < Minitest::Test | |
| 834 906 | 
             
              end
         | 
| 835 907 |  | 
| 836 908 | 
             
              class Keywords
         | 
| 837 | 
            -
                def self.args req, kw1:, kw2:24
         | 
| 909 | 
            +
                def self.args req, kw1:, kw2: 24
         | 
| 838 910 | 
             
                  [req, kw1, kw2]
         | 
| 839 911 | 
             
                end
         | 
| 840 912 | 
             
              end
         | 
| @@ -848,7 +920,7 @@ class TestMinitestStub < Minitest::Test | |
| 848 920 | 
             
              def test_stub__hash_as_last_real_arg
         | 
| 849 921 | 
             
                with_kwargs_env do
         | 
| 850 922 | 
             
                  token = Object.new
         | 
| 851 | 
            -
                  def token.create_with_retry  | 
| 923 | 
            +
                  def token.create_with_retry _u, _p; raise "shouldn't see this"; end
         | 
| 852 924 |  | 
| 853 925 | 
             
                  controller = Object.new
         | 
| 854 926 | 
             
                  controller.define_singleton_method :create do |u, p|
         | 
| @@ -956,7 +1028,7 @@ class TestMinitestStub < Minitest::Test | |
| 956 1028 | 
             
              def test_stub_lambda_block_call_5
         | 
| 957 1029 | 
             
                @assertion_count += 1
         | 
| 958 1030 | 
             
                rs = nil
         | 
| 959 | 
            -
                io = StringIO.new | 
| 1031 | 
            +
                io = StringIO.new(+"", "w")
         | 
| 960 1032 | 
             
                File.stub5 :open, lambda { |p, m, &blk| blk and blk.call io } do
         | 
| 961 1033 | 
             
                  File.open "foo.txt", "r" do |f|
         | 
| 962 1034 | 
             
                    rs = f && f.write("woot")
         | 
| @@ -971,10 +1043,10 @@ class TestMinitestStub < Minitest::Test | |
| 971 1043 |  | 
| 972 1044 | 
             
                @assertion_count += 1
         | 
| 973 1045 | 
             
                rs = nil
         | 
| 974 | 
            -
                io = StringIO.new | 
| 1046 | 
            +
                io = StringIO.new(+"", "w")
         | 
| 975 1047 | 
             
                File.stub6 :open, lambda { |p, m, &blk| blk.call io } do
         | 
| 976 1048 | 
             
                  File.open "foo.txt", "r" do |f|
         | 
| 977 | 
            -
                    rs = f.write | 
| 1049 | 
            +
                    rs = f.write "woot"
         | 
| 978 1050 | 
             
                  end
         | 
| 979 1051 | 
             
                end
         | 
| 980 1052 | 
             
                @tc.assert_equal 4, rs
         | 
| @@ -984,10 +1056,10 @@ class TestMinitestStub < Minitest::Test | |
| 984 1056 | 
             
              def test_stub_lambda_block_call_args_5
         | 
| 985 1057 | 
             
                @assertion_count += 1
         | 
| 986 1058 | 
             
                rs = nil
         | 
| 987 | 
            -
                io = StringIO.new | 
| 1059 | 
            +
                io = StringIO.new(+"", "w")
         | 
| 988 1060 | 
             
                File.stub5(:open, lambda { |p, m, &blk| blk and blk.call io }, :WTF?) do
         | 
| 989 1061 | 
             
                  File.open "foo.txt", "r" do |f|
         | 
| 990 | 
            -
                    rs = f.write | 
| 1062 | 
            +
                    rs = f.write "woot"
         | 
| 991 1063 | 
             
                  end
         | 
| 992 1064 | 
             
                end
         | 
| 993 1065 | 
             
                @tc.assert_equal 4, rs
         | 
| @@ -999,10 +1071,10 @@ class TestMinitestStub < Minitest::Test | |
| 999 1071 |  | 
| 1000 1072 | 
             
                @assertion_count += 1
         | 
| 1001 1073 | 
             
                rs = nil
         | 
| 1002 | 
            -
                io = StringIO.new | 
| 1074 | 
            +
                io = StringIO.new(+"", "w")
         | 
| 1003 1075 | 
             
                File.stub6(:open, lambda { |p, m, &blk| blk.call io }, :WTF?) do
         | 
| 1004 1076 | 
             
                  File.open "foo.txt", "r" do |f|
         | 
| 1005 | 
            -
                    rs = f.write | 
| 1077 | 
            +
                    rs = f.write "woot"
         | 
| 1006 1078 | 
             
                  end
         | 
| 1007 1079 | 
             
                end
         | 
| 1008 1080 | 
             
                @tc.assert_equal 4, rs
         | 
| @@ -1014,11 +1086,11 @@ class TestMinitestStub < Minitest::Test | |
| 1014 1086 |  | 
| 1015 1087 | 
             
                @assertion_count += 2
         | 
| 1016 1088 | 
             
                rs = nil
         | 
| 1017 | 
            -
                io = StringIO.new | 
| 1089 | 
            +
                io = StringIO.new(+"", "w")
         | 
| 1018 1090 | 
             
                @tc.assert_raises ArgumentError do
         | 
| 1019 1091 | 
             
                  File.stub6_2(:open, lambda { |p, m, &blk| blk.call io }, :WTF?) do
         | 
| 1020 1092 | 
             
                    File.open "foo.txt", "r" do |f|
         | 
| 1021 | 
            -
                      rs = f.write | 
| 1093 | 
            +
                      rs = f.write "woot"
         | 
| 1022 1094 | 
             
                    end
         | 
| 1023 1095 | 
             
                  end
         | 
| 1024 1096 | 
             
                end
         | 
| @@ -1064,10 +1136,10 @@ class TestMinitestStub < Minitest::Test | |
| 1064 1136 | 
             
              def test_stub_value_block_args_5
         | 
| 1065 1137 | 
             
                @assertion_count += 2
         | 
| 1066 1138 | 
             
                rs = nil
         | 
| 1067 | 
            -
                io = StringIO.new | 
| 1139 | 
            +
                io = StringIO.new(+"", "w")
         | 
| 1068 1140 | 
             
                File.stub5 :open, :value, io do
         | 
| 1069 1141 | 
             
                  result = File.open "foo.txt", "r" do |f|
         | 
| 1070 | 
            -
                    rs = f.write | 
| 1142 | 
            +
                    rs = f.write "woot"
         | 
| 1071 1143 | 
             
                  end
         | 
| 1072 1144 | 
             
                  @tc.assert_equal :value, result
         | 
| 1073 1145 | 
             
                end
         | 
| @@ -1092,11 +1164,11 @@ class TestMinitestStub < Minitest::Test | |
| 1092 1164 |  | 
| 1093 1165 | 
             
                @assertion_count += 2
         | 
| 1094 1166 | 
             
                rs = nil
         | 
| 1095 | 
            -
                io = StringIO.new | 
| 1167 | 
            +
                io = StringIO.new(+"", "w")
         | 
| 1096 1168 | 
             
                assert_deprecated do
         | 
| 1097 1169 | 
             
                  File.stub6 :open, :value, io do
         | 
| 1098 1170 | 
             
                    result = File.open "foo.txt", "r" do |f|
         | 
| 1099 | 
            -
                      rs = f.write | 
| 1171 | 
            +
                      rs = f.write "woot"
         | 
| 1100 1172 | 
             
                    end
         | 
| 1101 1173 | 
             
                    @tc.assert_equal :value, result
         | 
| 1102 1174 | 
             
                  end
         | 
| @@ -1110,7 +1182,7 @@ class TestMinitestStub < Minitest::Test | |
| 1110 1182 |  | 
| 1111 1183 | 
             
                @assertion_count += 2
         | 
| 1112 1184 | 
             
                rs = nil
         | 
| 1113 | 
            -
                io = StringIO.new | 
| 1185 | 
            +
                io = StringIO.new(+"", "w")
         | 
| 1114 1186 | 
             
                @tc.assert_raises ArgumentError do
         | 
| 1115 1187 | 
             
                  File.stub6_2 :open, :value, io do
         | 
| 1116 1188 | 
             
                    result = File.open "foo.txt", "r" do |f|
         |