Skip to content

Commit

Permalink
[Fix rubocop#64] Fix Minitest/GlobalExpectations autocorrection for…
Browse files Browse the repository at this point in the history
… chained methods

Closes rubocop#64
  • Loading branch information
tejasbubane committed Mar 10, 2020
1 parent 0bc6c61 commit b8f9e99
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
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)

### Bug fixes

* [#60](https:/rubocop-hq/rubocop-minitest/issues/60): Fix `Minitest/GlobalExpectations` autocorrection for chained methods. ([@tejasbubane][])

## 0.7.0 (2020-03-09)

### New features
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/minitest/global_expectations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def autocorrect(node)
return unless global_expectation?(node)

lambda do |corrector|
receiver = node.receiver.loc.selector
receiver = node.receiver.source_range

if BLOCK_MATCHERS.include?(node.method_name)
corrector.insert_before(receiver, '_ { ')
Expand Down
6 changes: 6 additions & 0 deletions test/rubocop/cop/minitest/global_expectations_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ def test_works_with_chained_method_calls
^^^^^^^^^^^^^^^^^^^^^^^ Prefer using `_(A.foo.bar).must_equal 42`.
end
RUBY

assert_correction(<<~RUBY)
it 'does something' do
_(A.foo.bar).must_equal 42
end
RUBY
end

RuboCop::Cop::Minitest::GlobalExpectations::BLOCK_MATCHERS.each do |matcher|
Expand Down

0 comments on commit b8f9e99

Please sign in to comment.