Skip to content

Commit

Permalink
Fixed typo for AssertIncludes cop. Changed includes -> include
Browse files Browse the repository at this point in the history
  • Loading branch information
abhaynikam committed Oct 1, 2019
1 parent 89d9ef7 commit 18aaef6
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion config/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Minitest/AssertEmpty:
VersionAdded: '0.2'

Minitest/AssertIncludes:
Description: 'Check if your test uses `assert_includes` instead of `assert(collection.includes?(actual))`.'
Description: 'Check if your test uses `assert_includes` instead of `assert(collection.include?(actual))`.'
StyleGuide: 'https://github.com/rubocop-hq/minitest-style-guide#assert-includes'
Enabled: true
VersionAdded: '0.2'
Expand Down
8 changes: 4 additions & 4 deletions lib/rubocop/cop/minitest/assert_includes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ module RuboCop
module Cop
module Minitest
# Check if your test uses `assert_includes`
# instead of `assert(collection.includes?(actual))`.
# instead of `assert(collection.include?(actual))`.
#
# @example
# # bad
# assert(collection.includes?(actual))
# assert(collection.includes?(actual), 'the message')
# assert(collection.include?(actual))
# assert(collection.include?(actual), 'the message')
#
# # good
# assert_includes(collection, actual)
Expand All @@ -20,7 +20,7 @@ class AssertIncludes < Cop
'`assert(%<receiver>s)`.'

def_node_matcher :assert_with_includes, <<~PATTERN
(send nil? :assert $(send $_ :includes? $_) $...)
(send nil? :assert $(send $_ :include? $_) $...)
PATTERN

def on_send(node)
Expand Down
6 changes: 3 additions & 3 deletions manual/cops_minitest.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChan
Enabled | Yes | Yes | 0.2 | -

Check if your test uses `assert_includes`
instead of `assert(collection.includes?(actual))`.
instead of `assert(collection.include?(actual))`.

### Examples

```ruby
# bad
assert(collection.includes?(actual))
assert(collection.includes?(actual), 'the message')
assert(collection.include?(actual))
assert(collection.include?(actual), 'the message')

# good
assert_includes(collection, actual)
Expand Down
24 changes: 12 additions & 12 deletions test/rubocop/cop/minitest/assert_includes_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ def setup
@cop = RuboCop::Cop::Minitest::AssertIncludes.new
end

def test_registers_offense_when_using_assert_with_includes
def test_registers_offense_when_using_assert_with_include
assert_offense(<<~RUBY, @cop)
class FooTest < Minitest::Test
def test_do_something
assert(collection.includes?(actual))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Prefer using `assert_includes(collection, actual)` over `assert(collection.includes?(actual))`.
assert(collection.include?(actual))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Prefer using `assert_includes(collection, actual)` over `assert(collection.include?(actual))`.
end
end
RUBY
Expand All @@ -26,12 +26,12 @@ def test_do_something
RUBY
end

def test_registers_offense_when_using_assert_with_includes_and_message
def test_registers_offense_when_using_assert_with_include_and_message
assert_offense(<<~RUBY, @cop)
class FooTest < Minitest::Test
def test_do_something
assert(collection.includes?(actual), 'the message')
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Prefer using `assert_includes(collection, actual, 'the message')` over `assert(collection.includes?(actual), 'the message')`.
assert(collection.include?(actual), 'the message')
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Prefer using `assert_includes(collection, actual, 'the message')` over `assert(collection.include?(actual), 'the message')`.
end
end
RUBY
Expand All @@ -45,13 +45,13 @@ def test_do_something
RUBY
end

def test_registers_offense_when_using_assert_with_includes_and_variable_message
def test_registers_offense_when_using_assert_with_include_and_variable_message
assert_offense(<<~RUBY, @cop)
class FooTest < Minitest::Test
def test_do_something
message = 'the message'
assert(collection.includes?(actual), message)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Prefer using `assert_includes(collection, actual, message)` over `assert(collection.includes?(actual), message)`.
assert(collection.include?(actual), message)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Prefer using `assert_includes(collection, actual, message)` over `assert(collection.include?(actual), message)`.
end
end
RUBY
Expand All @@ -66,14 +66,14 @@ def test_do_something
RUBY
end

def test_registers_offense_when_using_assert_with_includes_and_constant_message
def test_registers_offense_when_using_assert_with_include_and_constant_message
assert_offense(<<~RUBY, @cop)
class FooTest < Minitest::Test
MESSAGE = 'the message'
def test_do_something
assert(collection.includes?(actual), MESSAGE)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Prefer using `assert_includes(collection, actual, MESSAGE)` over `assert(collection.includes?(actual), MESSAGE)`.
assert(collection.include?(actual), MESSAGE)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Prefer using `assert_includes(collection, actual, MESSAGE)` over `assert(collection.include?(actual), MESSAGE)`.
end
end
RUBY
Expand Down

0 comments on commit 18aaef6

Please sign in to comment.