Class: RuboCop::Cop::RSpec::Rails::NegationBeValid

Inherits:
Base
  • Object
show all
Defined in:
lib/rubocop/cop/rspec/rails/negation_be_valid.rb

Overview

Enforces use of ‘be_invalid` or `not_to` for negated be_valid.

Examples:

EnforcedStyle: not_to (default)

# bad
expect(foo).to be_invalid

# good
expect(foo).not_to be_valid

# good (with method chain)
expect(foo).to be_invalid.and be_odd

EnforcedStyle: be_invalid

# bad
expect(foo).not_to be_valid

# good
expect(foo).to be_invalid

# good (with method chain)
expect(foo).to be_invalid.or be_even

Method Summary

Methods inherited from Base

inherited, #on_new_investigation

Methods included from RSpec::Language::NodePattern

#block_or_numblock_pattern, #block_pattern, #numblock_pattern, #send_pattern

Methods included from RSpec::Language

#example?, #example_group?, #example_group_with_body?, #explicit_rspec?, #hook?, #include?, #let?, #rspec?, #shared_group?, #spec_group?, #subject?