Permalink
Browse files

+ Deprecated use of global expectations. To be removed from MT6.

[git-p4: depot-paths = "//src/minitest/dev/": change = 11569]
  • Loading branch information...
zenspider committed Mar 6, 2018
1 parent 879dc1c commit e6bc4485730403faff6966c1671cf5de72b2d233
Showing with 15 additions and 0 deletions.
  1. +3 −0 lib/minitest/spec.rb
  2. +12 −0 test/minitest/test_minitest_spec.rb
@@ -8,6 +8,9 @@ def infect_an_assertion meth, new_name, dont_flip = false # :nodoc:
# warn "%-22p -> %p %p" % [meth, new_name, dont_flip]
self.class_eval <<-EOM, __FILE__, __LINE__ + 1
def #{new_name} *args
where = Minitest.filter_backtrace(caller).first
where = where.split(/:in /, 2).first # clean up noise
warn "DEPRECATED: global use of #{new_name} from #\{where}. Use _(obj).#{new_name} instead. This will fail in Minitest 6."
Minitest::Expectation.new(self, Minitest::Spec.current).#{new_name}(*args)
end
EOM
@@ -535,6 +535,18 @@ def assert_triggered expected = "blah", klass = Minitest::Assertion

assert_equal "Calling #must_equal outside of test.", e.message
end

it "deprecates expectation used without _" do
skip "N/A" if ENV["MT_NO_EXPECTATIONS"]

@assertion_count += 3

exp = /DEPRECATED: global use of must_equal from/

assert_output "", exp do
(1 + 1).must_equal 2
end
end
end

it "needs to verify throw" do

0 comments on commit e6bc448

Please sign in to comment.