class TestMinitestRunnable

Public Instance Methods

assert_marshal(expected_ivars) { |new_tc| ... } click to toggle source
# File minitest-5.13.0/test/minitest/test_minitest_test.rb, line 766
def assert_marshal expected_ivars
  new_tc = Marshal.load Marshal.dump @tc

  ivars = new_tc.instance_variables.map(&:to_s).sort
  assert_equal expected_ivars, ivars
  assert_equal "whatever",     new_tc.name
  assert_equal 42,             new_tc.assertions
  assert_equal ["a failure"],  new_tc.failures

  yield new_tc if block_given?
end
setup_marshal(klass) { |tc| ... } click to toggle source
# File minitest-5.13.0/test/minitest/test_minitest_test.rb, line 751
def setup_marshal klass
  tc = klass.new "whatever"
  tc.assertions = 42
  tc.failures << "a failure"

  yield tc if block_given?

  def tc.setup
    @blah = "blah"
  end
  tc.setup

  @tc = Minitest::Result.from tc
end
test_marshal() click to toggle source
# File minitest-5.13.0/test/minitest/test_minitest_test.rb, line 778
def test_marshal
  setup_marshal Minitest::Runnable

  assert_marshal %w[@NAME @assertions @failures @klass @source_location @time]
end
test_spec_marshal() click to toggle source
# File minitest-5.13.0/test/minitest/test_minitest_test.rb, line 784
def test_spec_marshal
  klass = describe("whatever") { it("passes") { assert true } }
  rm = klass.runnable_methods.first

  # Run the test
  @tc = klass.new(rm).run

  assert_kind_of Minitest::Result, @tc

  # Pass it over the wire
  over_the_wire = Marshal.load Marshal.dump @tc

  assert_equal @tc.time,       over_the_wire.time
  assert_equal @tc.name,       over_the_wire.name
  assert_equal @tc.assertions, over_the_wire.assertions
  assert_equal @tc.failures,   over_the_wire.failures
  assert_equal @tc.klass,      over_the_wire.klass
end