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

Inherits:
Cop
  • Object
show all
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`.'

Constants inherited from Cop

Cop::DEFAULT_CONFIGURATION, Cop::DEFAULT_PATTERN_RE

Constants included from RSpec::Language

RSpec::Language::ALL, RSpec::Language::RSPEC

Instance Method Summary collapse

Methods inherited from Cop

inherited, #relevant_file?

Instance Method Details

#autocorrect(node) ⇒ Object



31
32
33
# File 'lib/rubocop/cop/rspec/not_to_not.rb', line 31

def autocorrect(node)
  ->(corrector) { corrector.replace(node.loc.selector, style.to_s) }
end

#on_send(node) ⇒ Object



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

def on_send(node)
  not_to_not_offense(node, alternative_style) do
    add_offense(node, location: :selector)
  end
end