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

Some of Minitest Cops errors when used with minitest-power_assert #113

Closed
tsugimoto opened this issue Dec 9, 2020 · 0 comments · Fixed by #114
Closed

Some of Minitest Cops errors when used with minitest-power_assert #113

tsugimoto opened this issue Dec 9, 2020 · 0 comments · Fixed by #114
Labels
bug Something isn't working

Comments

@tsugimoto
Copy link

Expected behavior

minitest-power_assert extends the #assert method, which would accept a block without arguments:

assert { 1 + 2 == 3 }

While this is not valid code in plain minitest and it is expected to either emit or not emit some warnings, RuboCop warns it in a rather surprising way.

Actual behavior

An error occurred while Minitest/AssertEmpty cop was inspecting /.../test/foo.rb:1:0.
undefined method `begin_type?' for nil:NilClass
/.../gems/rubocop-minitest-0.10.1/lib/rubocop/cop/mixin/minitest_cop_rule.rb:59:in `peel_redundant_parentheses_from'
/.../gems/rubocop-minitest-0.10.1/lib/rubocop/cop/mixin/minitest_cop_rule.rb:34:in `on_send'
/.../gems/rubocop-1.5.2/lib/rubocop/cop/commissioner.rb:100:in `public_send'
/.../gems/rubocop-1.5.2/lib/rubocop/cop/commissioner.rb:100:in `block (2 levels) in trigger_responding_cops'
/.../gems/rubocop-1.5.2/lib/rubocop/cop/commissioner.rb:166:in `with_cop_error_handling'
6 errors occurred:
An error occurred while Minitest/AssertEmpty cop was inspecting /.../test/foo.rb:1:0.
An error occurred while Minitest/AssertEqual cop was inspecting /.../test/foo.rb:1:0.
An error occurred while Minitest/AssertIncludes cop was inspecting /.../test/foo.rb:1:0.
An error occurred while Minitest/AssertInstanceOf cop was inspecting /.../test/foo.rb:1:0.
An error occurred while Minitest/AssertMatch cop was inspecting /.../test/foo.rb:1:0.
An error occurred while Minitest/AssertRespondTo cop was inspecting /.../test/foo.rb:1:0.
Errors are usually caused by RuboCop bugs.
Please, report your problems to RuboCop's issue tracker.
https://github.com/rubocop-hq/rubocop/issues

Steps to reproduce the problem

Inside a project configured to use rubocop-minitest, create a file test/foo.rb with content:

assert { 1 + 2 == 3 }

Then run:

$ rubocop test/foo.rb

RuboCop version

1.5.2 (using Parser 2.7.2.0, rubocop-ast 1.3.0, running on ruby 2.6.3 x86_64-darwin18)
@koic koic added the bug Something isn't working label Dec 9, 2020
koic added a commit to koic/rubocop-minitest that referenced this issue Dec 24, 2020
Fixes rubocop#113.

This PR fixes an error for `Minitest/AssertEqual` and some cops
when using `assert` with block argument.
@koic koic closed this as completed in #114 Dec 25, 2020
koic added a commit that referenced this issue Dec 25, 2020
[Fix #113] Fix an error for `Minitest/AssertEqual`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants