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

Minitest/MultipleAssertions error #284

Closed
broksonic21 opened this issue Dec 19, 2023 · 5 comments
Closed

Minitest/MultipleAssertions error #284

broksonic21 opened this issue Dec 19, 2023 · 5 comments
Labels
duplicate This issue or pull request already exists

Comments

@broksonic21
Copy link

Expected behavior

Bumping to 0.34.1 shouldn't return errors, but getting throughout our code base

Actual behavior


Offenses:

REDACTED:73:7: W: Minitest/MultipleAssertions: Test case has too many assertions [4/3].
      def test_REDACTED ...
      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
REDACTED:85:7: W: Minitest/MultipleAssertions: Test case has too many assertions [18/3].
      def test_REDACTED ...
      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

1 file inspected, 2 offenses detected

1 error occurred:
An error occurred while Minitest/MultipleAssertions cop was inspecting REDACTED:7:4.
Errors are usually caused by RuboCop bugs.
Please, report your problems to RuboCop's issue tracker.
https://github.com/rubocop/rubocop/issues

Mention the following information in the issue report:
1.59.0 (using Parser 3.2.2.4, rubocop-ast 1.30.0, running on ruby 3.0.6) [arm64-darwin22]

Steps to reproduce the problem

dont' have a private repo yet, but seeing this through out code base. Is there a way to get even deeper verbose logs?

RuboCop version

1.59.0 (using Parser 3.2.2.4, rubocop-ast 1.30.0, running on ruby 3.0.6) [arm64-darwin22]
  - rubocop-capybara 2.19.0
  - rubocop-graphql 1.4.0
  - rubocop-minitest 0.34.1
  - rubocop-performance 1.20.0
  - rubocop-rails 2.23.0
  - rubocop-rake 0.6.0
@andyw8
Copy link
Contributor

andyw8 commented Dec 19, 2023

You can pass the --debug option. But it would be best if you can provide a minimal example of the code it's being run against.

@broksonic21
Copy link
Author

Looks like it's here: https://github.com/rubocop/rubocop-minitest/blob/master/lib/rubocop/cop/mixin/minitest_exploration_helpers.rb#L104

An error occurred while Minitest/MultipleAssertions cop was inspecting /Users/REDACTED/REDACTED:7:4.
undefined method `assignment?' for nil:NilClass
/Users/REDACTED/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/rubocop-minitest-0.34.1/lib/rubocop/cop/mixin/minitest_exploration_helpers.rb:104:in `assertion_method?'
/Users/REDACTED/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/rubocop-minitest-0.34.1/lib/rubocop/cop/mixin/minitest_exploration_helpers.rb:104:in `assertion_method?'
/Users/REDACTED/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/rubocop-minitest-0.34.1/lib/rubocop/cop/minitest/multiple_assertions.rb:68:in `assertions_count'
/Users/REDACTED/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/rubocop-minitest-0.34.1/lib/rubocop/cop/minitest/multiple_assertions.rb:65:in `block in assertions_count'
/Users/REDACTED/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/rubocop-ast-1.30.0/lib/rubocop/ast/node/mixin/descendence.rb:28:in `block in each_child_node'
/Users/REDACTED/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/rubocop-ast-1.30.0/lib/rubocop/ast/node/mixin/descendence.rb:25:in `each'
/Users/REDACTED/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/rubocop-ast-1.30.0/lib/rubocop/ast/node/mixin/descendence.rb:25:in `each_child_node'
/Users/REDACTED/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/rubocop-minitest-0.34.1/lib/rubocop/cop/minitest/multiple_assertions.rb:65:in `each'
/Users/REDACTED/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/rubocop-minitest-0.34.1/lib/rubocop/cop/minitest/multiple_assertions.rb:65:in `sum'
/Users/REDACTED/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/rubocop-minitest-0.34.1/lib/rubocop/cop/minitest/multiple_assertions.rb:65:in `assertions_count'
/Users/REDACTED/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/rubocop-minitest-0.34.1/lib/rubocop/cop/minitest/multiple_assertions.rb:65:in `block in assertions_count'
/Users/REDACTED/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/rubocop-ast-1.30.0/lib/rubocop/ast/node/mixin/descendence.rb:28:in `block in each_child_node'
/Users/REDACTED/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/rubocop-ast-1.30.0/lib/rubocop/ast/node/mixin/descendence.rb:25:in `each'
/Users/REDACTED/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/rubocop-ast-1.30.0/lib/rubocop/ast/node/mixin/descendence.rb:25:in `each_child_node'
/Users/REDACTED/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/rubocop-minitest-0.34.1/lib/rubocop/cop/minitest/multiple_assertions.rb:65:in `each'
/Users/REDACTED/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/rubocop-minitest-0.34.1/lib/rubocop/cop/minitest/multiple_assertions.rb:65:in `sum'
/Users/REDACTED/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/rubocop-minitest-0.34.1/lib/rubocop/cop/minitest/multiple_assertions.rb:65:in `assertions_count'
/Users/REDACTED/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/rubocop-minitest-0.34.1/lib/rubocop/cop/minitest/multiple_assertions.rb:65:in `block in assertions_count'
/Users/REDACTED/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/rubocop-ast-1.30.0/lib/rubocop/ast/node/mixin/descendence.rb:28:in `block in each_child_node'
/Users/REDACTED/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/rubocop-ast-1.30.0/lib/rubocop/ast/node/mixin/descendence.rb:25:in `each'

@broksonic21
Copy link
Author

# frozen_string_literal: true

class FooTest < ::Test

  def test_it_fails
    _, b = try_update(foo: 3) do
      see(bar: c.bar, baz: "baz")
    end

    assert_eq c.id, b.id
    assert_eq c.foo, b.foo
  end

end

reproes this.

@broksonic21
Copy link
Author

nothing to do with asserts, it looks like:

# frozen_string_literal: true

class FooTest < ::Test

  def test_it_fails
    _d, _b = try_update(foo: 3) do
      see(bar: c.bar, baz: "baz")
    end
  end

end

has same error - must be anytime there's a split return value?

@koic koic added the duplicate This issue or pull request already exists label Dec 20, 2023
@koic
Copy link
Member

koic commented Dec 20, 2023

This issue is a dup with #283. Thank you for your feedback.

@koic koic closed this as completed Dec 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

3 participants