class TestSpecInTestCase

Public Instance Methods

assert_triggered(expected, klass = Minitest::Assertion) { || ... } click to toggle source
# File minitest-5.13.0/test/minitest/test_minitest_spec.rb, line 983
def assert_triggered expected, klass = Minitest::Assertion
  @assertion_count += 1

  e = assert_raises klass do
    yield
  end

  msg = e.message.sub(/(---Backtrace---).*/m, "\1")
  msg.gsub!(/\(oid=[-0-9]+\)/, "(oid=N)")

  assert_equal expected, msg
end
setup() click to toggle source
Calls superclass method MetaMetaMetaTestCase#setup
# File minitest-5.13.0/test/minitest/test_minitest_spec.rb, line 975
def setup
  super

  Thread.current[:current_spec] = self
  @tc = self
  @assertion_count = 2
end
teardown() click to toggle source
# File minitest-5.13.0/test/minitest/test_minitest_spec.rb, line 996
def teardown
  msg = "expected #{@assertion_count} assertions, not #{@tc.assertions}"
  assert_equal @assertion_count, @tc.assertions, msg
end
test_expectation() click to toggle source
# File minitest-5.13.0/test/minitest/test_minitest_spec.rb, line 1001
def test_expectation
  @tc.assert_equal true, _(1).must_equal(1)
end
test_expectation_triggered() click to toggle source
# File minitest-5.13.0/test/minitest/test_minitest_spec.rb, line 1005
def test_expectation_triggered
  assert_triggered "Expected: 2\n  Actual: 1" do
    _(1).must_equal 2
  end
end
test_expectation_with_a_message() click to toggle source
# File minitest-5.13.0/test/minitest/test_minitest_spec.rb, line 1013
def test_expectation_with_a_message
  assert_triggered "woot.\nExpected: 2\n  Actual: 1" do
    _(1).must_equal 2, "woot"
  end
end