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 #66] Support all expectations of Minitest::Expectations #67

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## master (unreleased)

### New features

* [#66](https://github.com/rubocop-hq/rubocop-minitest/issues/66): Support all expectations of `Minitest::Expectations` for `Minitest/GlobalExpectations` cop. ([@koic][])

### Bug fixes

* [#60](https://github.com/rubocop-hq/rubocop-minitest/issues/60): Fix `Minitest/GlobalExpectations` autocorrection for chained methods. ([@tejasbubane][])
Expand Down
15 changes: 8 additions & 7 deletions lib/rubocop/cop/minitest/global_expectations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,15 @@ class GlobalExpectations < Cop
MSG = 'Prefer using `%<corrected>s`.'

VALUE_MATCHERS = %i[
be be_close_to be_empty be_instance_of be_kind_of
be_nil be_same_as be_silent be_within_epsilon equal
include match respond_to must_exist
].map do |matcher|
[:"must_#{matcher}", :"wont_#{matcher}"]
end.flatten.freeze
must_be_empty must_equal must_be_close_to must_be_within_delta
must_be_within_epsilon must_include must_be_instance_of must_be_kind_of
must_match must_be_nil must_be must_respond_to must_be_same_as
path_must_exist path_wont_exist wont_be_empty wont_equal wont_be_close_to
wont_be_within_delta wont_be_within_epsilon wont_include wont_be_instance_of
wont_be_kind_of wont_match wont_be_nil wont_be wont_respond_to wont_be_same_as
].freeze

BLOCK_MATCHERS = %i[must_output must_raise must_throw].freeze
BLOCK_MATCHERS = %i[must_output must_raise must_be_silent must_throw].freeze

MATCHERS_STR = (VALUE_MATCHERS + BLOCK_MATCHERS).map do |m|
":#{m}"
Expand Down