class RuboCop::Cop::RSpec::BeEmpty

Prefer using ‘be_empty` when checking for an empty array.

@example

# bad
expect(array).to contain_exactly
expect(array).to match_array([])

# good
expect(array).to be_empty

Constants

MSG
RESTRICT_ON_SEND

Public Instance Methods

on_send(node) click to toggle source
# File lib/rubocop/cop/rspec/be_empty.rb, line 35
def on_send(node)
  expect_array_matcher?(node.parent) do |expect|
    add_offense(expect) do |corrector|
      corrector.replace(expect, 'be_empty')
    end
  end
end