Skip to content

Commit

Permalink
+ Deprecated use of global expectations. To be removed from MT6.
Browse files Browse the repository at this point in the history
[git-p4: depot-paths = "//src/minitest/dev/": change = 11569]
  • Loading branch information
zenspider committed Mar 6, 2018
1 parent 879dc1c commit e6bc448
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/minitest/spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 12 additions & 0 deletions test/minitest/test_minitest_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e6bc448

Please sign in to comment.