Class: RuboCop::Cop::RSpec::NotToNot

Inherits:
Base
  • Object
show all
Extended by:
AutoCorrector
Includes:
ConfigurableEnforcedStyle
Defined in:
lib/rubocop/cop/rspec/not_to_not.rb

Overview

Checks for consistent method usage for negating expectations.

Examples:

# bad
it '...' do
  expect(false).to_not be_true
end

# good
it '...' do
  expect(false).not_to be_true
end

Constant Summary collapse

MSG =
'Prefer `%<replacement>s` over `%<original>s`.'

Instance Method Summary collapse

Methods inherited from Base

inherited, #on_new_investigation

Methods included from RSpec::Language::NodePattern

#block_pattern, #send_pattern

Instance Method Details

#on_send(node) ⇒ Object



26
27
28
29
30
31
32
# File 'lib/rubocop/cop/rspec/not_to_not.rb', line 26

def on_send(node)
  not_to_not_offense(node, alternative_style) do
    add_offense(node.loc.selector) do |corrector|
      corrector.replace(node.loc.selector, style.to_s)
    end
  end
end