Class: TestMinitestAssertionHelpers

Inherits:
Minitest::Test show all
Defined in:
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/test/minitest/test_minitest_assertions.rb

Constant Summary

Constants inherited from Minitest::Test

Minitest::Test::PASSTHROUGH_EXCEPTIONS, Minitest::Test::SETUP_METHODS, Minitest::Test::TEARDOWN_METHODS

Constants included from Minitest::Assertions

Minitest::Assertions::E, Minitest::Assertions::UNDEFINED

Constants inherited from Minitest::Runnable

Minitest::Runnable::SIGNALS

Instance Attribute Summary

Attributes inherited from Minitest::Runnable

#assertions, #failures, #time

Instance Method Summary collapse

Methods inherited from Minitest::Test

#capture_exceptions, #class_name, #clean, i_suck_and_my_tests_are_order_dependent!, make_my_diffs_pretty!, #neuter_exception, #new_exception, parallelize_me!, #run, runnable_methods, #sanitize_exception, test_order, #with_empty_backtrace_filter, #with_info_handler

Methods included from Minitest::Guard

#jruby?, #maglev?, #mri?, #osx?, #rubinius?, #windows?

Methods included from Minitest::Test::LifecycleHooks

#after_setup, #after_teardown, #before_setup, #before_teardown, #setup, #teardown

Methods included from Minitest::Reportable

#class_name, #error?, #location, #passed?, #result_code, #skipped?

Methods included from Minitest::Assertions

#_synchronize, #assert, #assert_empty, #assert_equal, #assert_in_delta, #assert_in_epsilon, #assert_includes, #assert_instance_of, #assert_kind_of, #assert_match, #assert_mock, #assert_nil, #assert_operator, #assert_output, #assert_path_exists, #assert_predicate, #assert_raises, #assert_respond_to, #assert_same, #assert_send, #assert_silent, #assert_throws, #capture_io, #capture_subprocess_io, #diff, diff, diff=, #exception_details, #fail_after, #flunk, #message, #mu_pp, #mu_pp_for_diff, #pass, #refute, #refute_empty, #refute_equal, #refute_in_delta, #refute_in_epsilon, #refute_includes, #refute_instance_of, #refute_kind_of, #refute_match, #refute_nil, #refute_operator, #refute_path_exists, #refute_predicate, #refute_respond_to, #refute_same, #skip, #skip_until, #skipped?, #things_to_diff

Methods inherited from Minitest::Runnable

#failure, inherited, #initialize, #marshal_dump, #marshal_load, methods_matching, #name, #name=, on_signal, #passed?, reset, #result_code, run, #run, run_one_method, runnable_methods, runnables, #skipped?, #time_it, #whatever, with_info_handler

Constructor Details

This class inherits a constructor from Minitest::Runnable

Instance Method Details

#assert_mu_pp(exp, input, raw = false) ⇒ Object



1401
1402
1403
1404
1405
1406
1407
1408
1409
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/test/minitest/test_minitest_assertions.rb', line 1401

def assert_mu_pp exp, input, raw = false
  act = mu_pp input

  if String === input && !raw then
    assert_equal "\"#{exp}\"", act
  else
    assert_equal exp, act
  end
end

#assert_mu_pp_for_diff(exp, input, raw = false) ⇒ Object



1411
1412
1413
1414
1415
1416
1417
1418
1419
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/test/minitest/test_minitest_assertions.rb', line 1411

def assert_mu_pp_for_diff exp, input, raw = false
  act = mu_pp_for_diff input

  if String === input && !raw then
    assert_equal "\"#{exp}\"", act
  else
    assert_equal exp, act
  end
end

#test_diff_equalObject



1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/test/minitest/test_minitest_assertions.rb', line 1421

def test_diff_equal
  msg = "No visible difference in the String#inspect output.
         You should look at the implementation of #== on String or its members.
         \"blahblahblahblahblahblahblahblahblahblah\"".gsub(/^ +/, "")

  o1 = "blah" * 10
  o2 = "blah" * 10
  def o1.== _
    false
  end

  assert_equal msg, diff(o1, o2)
end

#test_diff_str_mixedObject



1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/test/minitest/test_minitest_assertions.rb', line 1435

def test_diff_str_mixed
  msg = <<-'EOM'.gsub(/^ {10}/, "") # NOTE single quotes on heredoc
        --- expected
        +++ actual
        @@ -1 +1 @@
        -"A\\n\nB"
        +"A\n\\nB"
        EOM

  exp = "A\\n\nB"
  act = "A\n\\nB"

  assert_equal msg, diff(exp, act)
end

#test_diff_str_multilineObject



1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/test/minitest/test_minitest_assertions.rb', line 1450

def test_diff_str_multiline
  msg = <<-'EOM'.gsub(/^ {10}/, "") # NOTE single quotes on heredoc
        --- expected
        +++ actual
        @@ -1,2 +1,2 @@
         "A
        -B"
        +C"
        EOM

  exp = "A\nB"
  act = "A\nC"

  assert_equal msg, diff(exp, act)
end

#test_diff_str_simpleObject



1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/test/minitest/test_minitest_assertions.rb', line 1466

def test_diff_str_simple
  msg = <<-'EOM'.gsub(/^ {10}/, "").chomp # NOTE single quotes on heredoc
        Expected: "A"
          Actual: "B"
        EOM

  exp = "A"
  act = "B"

  assert_equal msg, diff(exp, act)
end

#test_messageObject



1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/test/minitest/test_minitest_assertions.rb', line 1478

def test_message
  assert_equal "blah2.",         message          { "blah2" }.call
  assert_equal "blah2.",         message("")      { "blah2" }.call
  assert_equal "blah1.\nblah2.", message(:blah1)  { "blah2" }.call
  assert_equal "blah1.\nblah2.", message("blah1") { "blah2" }.call

  message = proc { "blah1" }
  assert_equal "blah1.\nblah2.", message(message) { "blah2" }.call

  message = message { "blah1" }
  assert_equal "blah1.\nblah2.", message(message) { "blah2" }.call
end

#test_message_deferredObject



1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/test/minitest/test_minitest_assertions.rb', line 1491

def test_message_deferred
  var = nil

  msg = message { var = "blah" }

  assert_nil var

  msg.call

  assert_equal "blah", var
end

#test_mu_ppObject



1503
1504
1505
1506
1507
1508
1509
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/test/minitest/test_minitest_assertions.rb', line 1503

def test_mu_pp
  assert_mu_pp 42.inspect,            42
  assert_mu_pp %w[a b c].inspect,     %w[a b c]
  assert_mu_pp "A B",     "A B"
  assert_mu_pp "A\\nB",   "A\nB"
  assert_mu_pp "A\\\\nB", 'A\nB' # notice single quotes
end

#test_mu_pp_for_diffObject



1511
1512
1513
1514
1515
1516
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/test/minitest/test_minitest_assertions.rb', line 1511

def test_mu_pp_for_diff
  assert_mu_pp_for_diff "#<Object:0xXXXXXX>", Object.new
  assert_mu_pp_for_diff "A B",                "A B"
  assert_mu_pp_for_diff [1, 2, 3].inspect,    [1, 2, 3]
  assert_mu_pp_for_diff "A\nB",               "A\nB"
end

#test_mu_pp_for_diff_str_bad_encodingObject



1518
1519
1520
1521
1522
1523
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/test/minitest/test_minitest_assertions.rb', line 1518

def test_mu_pp_for_diff_str_bad_encoding
  str = "\666".force_encoding Encoding::UTF_8
  exp = "# encoding: UTF-8\n#    valid: false\n\"\\xB6\""

  assert_mu_pp_for_diff exp, str, :raw
end

#test_mu_pp_for_diff_str_bad_encoding_bothObject



1525
1526
1527
1528
1529
1530
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/test/minitest/test_minitest_assertions.rb', line 1525

def test_mu_pp_for_diff_str_bad_encoding_both
  str = "\666A\\n\nB".force_encoding Encoding::UTF_8
  exp = "# encoding: UTF-8\n#    valid: false\n\"\\xB6A\\\\n\\nB\""

  assert_mu_pp_for_diff exp, str, :raw
end

#test_mu_pp_for_diff_str_encodingObject



1532
1533
1534
1535
1536
1537
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/test/minitest/test_minitest_assertions.rb', line 1532

def test_mu_pp_for_diff_str_encoding
  str = "A\nB".b
  exp = "# encoding: #{Encoding::BINARY.name}\n#    valid: true\n\"A\nB\""

  assert_mu_pp_for_diff exp, str, :raw
end

#test_mu_pp_for_diff_str_encoding_bothObject



1539
1540
1541
1542
1543
1544
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/test/minitest/test_minitest_assertions.rb', line 1539

def test_mu_pp_for_diff_str_encoding_both
  str = "A\\n\nB".b
  exp = "# encoding: #{Encoding::BINARY.name}\n#    valid: true\n\"A\\\\n\\nB\""

  assert_mu_pp_for_diff exp, str, :raw
end

#test_mu_pp_for_diff_str_nerdObject



1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/test/minitest/test_minitest_assertions.rb', line 1546

def test_mu_pp_for_diff_str_nerd
  assert_mu_pp_for_diff "A\\nB\\\\nC", "A\nB\\nC"
  assert_mu_pp_for_diff "\\nB\\\\nC",  "\nB\\nC"
  assert_mu_pp_for_diff "\\nB\\\\n",   "\nB\\n"
  assert_mu_pp_for_diff "\\n\\\\n",    "\n\\n"
  assert_mu_pp_for_diff "\\\\n\\n",    "\\n\n"
  assert_mu_pp_for_diff "\\\\nB\\n",   "\\nB\n"
  assert_mu_pp_for_diff "\\\\nB\\nC",  "\\nB\nC"
  assert_mu_pp_for_diff "A\\\\n\\nB",  "A\\n\nB"
  assert_mu_pp_for_diff "A\\n\\\\nB",  "A\n\\nB"
  assert_mu_pp_for_diff "\\\\n\\n",    "\\n\n"
  assert_mu_pp_for_diff "\\n\\\\n",    "\n\\n"
end

#test_mu_pp_for_diff_str_normalObject



1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/test/minitest/test_minitest_assertions.rb', line 1560

def test_mu_pp_for_diff_str_normal
  assert_mu_pp_for_diff "",        ""
  assert_mu_pp_for_diff "A\\n\n",  "A\\n"
  assert_mu_pp_for_diff "A\\n\nB", "A\\nB"
  assert_mu_pp_for_diff "A\n",     "A\n"
  assert_mu_pp_for_diff "A\nB",    "A\nB"
  assert_mu_pp_for_diff "\\n\n",   "\\n"
  assert_mu_pp_for_diff "\n",      "\n"
  assert_mu_pp_for_diff "\\n\nA",  "\\nA"
  assert_mu_pp_for_diff "\nA",     "\nA"
end

#test_mu_pp_str_bad_encodingObject



1572
1573
1574
1575
1576
1577
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/test/minitest/test_minitest_assertions.rb', line 1572

def test_mu_pp_str_bad_encoding
  str = "\666".force_encoding Encoding::UTF_8
  exp = "# encoding: UTF-8\n#    valid: false\n\"\\xB6\""

  assert_mu_pp exp, str, :raw
end

#test_mu_pp_str_encodingObject



1579
1580
1581
1582
1583
1584
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/test/minitest/test_minitest_assertions.rb', line 1579

def test_mu_pp_str_encoding
  str = "A\nB".b
  exp = "# encoding: #{Encoding::BINARY.name}\n#    valid: true\n\"A\\nB\""

  assert_mu_pp exp, str, :raw
end

#test_mu_pp_str_immutableObject



1586
1587
1588
1589
1590
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/test/minitest/test_minitest_assertions.rb', line 1586

def test_mu_pp_str_immutable
  printer = Class.new { extend Minitest::Assertions }
  str = "test".freeze
  assert_equal '"test"', printer.mu_pp(str)
end