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

[Fix #155] Provide assert_offense and assert_no_offenses for custom cop development #156

Merged
merged 1 commit into from
Nov 20, 2021

Conversation

koic
Copy link
Member

@koic koic commented Nov 18, 2021

Resolves #155.

This PR provides assert_offense, assert_correction, and assert_no_offenses for custom Minitest cop development.

Developers can use these APIs by requesting the following in custom Minitest cop test code:

require 'rubocop/minitest/support'

Before submitting the PR make sure the following are checked:

  • Wrote good commit messages.
  • Commit message starts with [Fix #issue-number] (if the related issue exists).
  • Feature branch is up-to-date with master (if not - rebase it).
  • Squashed related commits together.
  • Added tests.
  • Added an entry (file) to the changelog folder named {change_type}_{change_description}.md if the new code introduces user-observable changes. See changelog entry format for details.
  • The PR relates to only one subject with a clear title
    and description in grammatically correct, complete sentences.
  • Run bundle exec rake default. It executes all tests and RuboCop for itself, and generates the documentation.

…or custom cop development

Resolves rubocop#155.

This PR provides `assert_offense`, `assert_correction`, and `assert_no_offenses`
testing APIs for custom Minitest cop development.

Developers can use these APIs by requesting the following in custom Minitest cop test code:

```ruby
require 'rubocop/minitest/support'
```
@koic koic merged commit 989d2b2 into rubocop:master Nov 20, 2021
@koic koic deleted the provide_assertion_apis branch November 20, 2021 08:23
@alex4787
Copy link

Thank you very much!

@koic
Copy link
Member Author

koic commented Nov 22, 2021

@alex4787 Yeah, I've just released 0.17.0 :-)
https://github.com/rubocop/rubocop-minitest/releases/tag/v0.17.0

@alex4787
Copy link

alex4787 commented Nov 22, 2021

@koic Thanks, appreciate the quick addition! And sorry to tack on another thing, but we were wondering if this could also be included in the main RuboCop gem as well, to provide a Minitest testing option (in addition to the RSpec testing API currently there) for any custom cop development, not only specific to Minitest-related cops.

@koic
Copy link
Member Author

koic commented Nov 22, 2021

Thank you for sharing your ideas. However, the APIs started with RuboCop Minitest's dogfooding. It wasn't essentially intended to have in the RuboCop core.
#1 (comment)

TBH, it would be undesirable to provide APIs for multiple testing frameworks in the RuboCop core. So, this API focuses on custom RuboCop Minitest development. Thank you.

@alex4787
Copy link

Got it, thanks for the context here. 😄

koic added a commit to koic/rubocop-minitest that referenced this pull request Oct 29, 2022
Follow up rubocop/rubocop#10987.

```console
% bundle exec rake
(snip)

NoMethodError: undefined method `disabled' for nil:NilClass

      registry.disabled(config).each do |cop|
               ^^^^^^^^^
    /Users/koic/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/bundler/gems/rubocop-479e588e16cd/lib/rubocop/comment_config.rb:94:in `inject_disabled_cops_directives'
    /Users/koic/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/bundler/gems/rubocop-479e588e16cd/lib/rubocop/comment_config.rb:78:in `analyze'
    /Users/koic/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/bundler/gems/rubocop-479e588e16cd/lib/rubocop/comment_config.rb:45:in `cop_disabled_line_ranges'
```

It supports multiple RuboCop core versions for compatibility with
rubocop#156.
@koic koic mentioned this pull request Oct 29, 2022
8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Include TestHelper and AssertionHelper in the gem
2 participants