Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support DEPRECATED: global use of must_equal from ... Use _(obj).must_equal instead. This will fail in Minitest 6. #60

Closed
yahonda opened this issue Mar 3, 2020 · 1 comment · Fixed by #63
Labels
enhancement New feature or request

Comments

@yahonda
Copy link
Contributor

yahonda commented Mar 3, 2020

Is your feature request related to a problem? Please describe.

While I'm working on googleapis/google-cloud-ruby#4884 , I've found that to prepare Ruby 3 keyword arguments support, minitest will require minitest/minitest#824 . I think it would mean the newer version of minitest will support Ruby 3.

On the other hand, gems under google-cloud-ruby repository lock the minitest version to use 5.11 or lower because minitest 5.12 shows DEPRECATED: global use of must_equal from must_equal.rb:28. Use _(obj).must_equal instead. This will fail in Minitest 6. Refer: https:/seattlerb/minitest/blob/master/History.rdoc#label-5.12.0+-2F+2019-09-22

I'm looking for some way to address this warning automatically to allow bump minitest version when it is ready to support Ruby 3 keyword arguments.

Describe the solution you'd like

It would be appreciated rubocop-minitest gem auto-corrects this warning.

Describe alternatives you've considered

Rewrite the test code by myself.

Additional context

Here are the steps to reproduce.

  • must_equal.rb
# frozen_string_literal: true

require 'bundler/inline'

gemfile(true) do
  source 'https://rubygems.org'
  git_source(:github) { |repo| "https:/#{repo}.git" }
  gem 'minitest'
end

# Avoid `Style/Documentation: Missing top-level class documentation comment.`
class Greeting
  def say_hello
    'Hello, World!'
  end

  def say_nothing; end
end

require 'minitest/autorun'
describe Greeting do
  before do
    @foo = Greeting.new
  end

  it 'must say hello world with a warning' do
    # Bad
    @foo.say_hello.must_equal 'Hello, World!'
  end

  it 'must say hello world without warning' do
    # Good
    _(@foo.say_hello).must_equal 'Hello, World!'
  end
end
  • Result showing DEPRECATED: global use of must_equal from must_equal.rb:28. Use _(obj).must_equal instead. This will fail in Minitest 6.
% ruby must_equal.rb
Fetching gem metadata from https://rubygems.org/..................
Resolving dependencies...
Using bundler 2.1.2
Using minitest 5.14.0
Run options: --seed 34922

# Running:

DEPRECATED: global use of must_equal from must_equal.rb:28. Use _(obj).must_equal instead. This will fail in Minitest 6.
..

Finished in 0.000651s, 3072.1966 runs/s, 3072.1966 assertions/s.

2 runs, 2 assertions, 0 failures, 0 errors, 0 skips
% ruby -v
ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-darwin19]
%
@koic
Copy link
Member

koic commented Mar 4, 2020

I think it is reasonable to respond to official warnings.

@koic koic added the enhancement New feature or request label Mar 4, 2020
tejasbubane added a commit to tejasbubane/rubocop-minitest that referenced this issue Mar 5, 2020
To check against deprecated global expectations. These will be removed
in Minitest 6.

Closes rubocop#60
tejasbubane added a commit to tejasbubane/rubocop-minitest that referenced this issue Mar 5, 2020
To check against deprecated global expectations. These will be removed
in Minitest 6.

Closes rubocop#60
tejasbubane added a commit to tejasbubane/rubocop-minitest that referenced this issue Mar 5, 2020
To check against deprecated global expectations. These will be removed
in Minitest 6.

Closes rubocop#60
tejasbubane added a commit to tejasbubane/rubocop-minitest that referenced this issue Mar 6, 2020
To check against deprecated global expectations. These will be removed
in Minitest 6.

Closes rubocop#60
tejasbubane added a commit to tejasbubane/rubocop-minitest that referenced this issue Mar 6, 2020
To check against deprecated global expectations. These will be removed
in Minitest 6.

Closes rubocop#60
tejasbubane added a commit to tejasbubane/rubocop-minitest that referenced this issue Mar 6, 2020
To check against deprecated global expectations. These will be removed
in Minitest 6.

Closes rubocop#60
tejasbubane added a commit to tejasbubane/rubocop-minitest that referenced this issue Mar 6, 2020
To check against deprecated global expectations. These will be removed
in Minitest 6.

Closes rubocop#60
tejasbubane added a commit to tejasbubane/rubocop-minitest that referenced this issue Mar 6, 2020
To check against deprecated global expectations. These will be removed
in Minitest 6.

Closes rubocop#60
@koic koic closed this as completed in #63 Mar 7, 2020
koic added a commit that referenced this issue Mar 7, 2020
[Fix #60] Add new cop `Minitest/GlobalExpectations`
koic added a commit to koic/rubocop-minitest that referenced this issue Dec 17, 2022
The cops below belong to linting, not style preference,
so make set the severity to warning.

The following emulates warnings for deprecated APIs:

- Minitest/GlobalExpectations (rubocop#60)

The following suggests incorrect usage of APIs:

- Minitest/AssertRaisesWithRegexpArgument:
- Minitest/AssertWithExpectedArgument:
- Minitest/SkipEnsure:
- Minitest/UnreachableAssertion:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants