File tree Expand file tree Collapse file tree 3 files changed +11
-1
lines changed
lib/rubocop/cop/rspec_rails
spec/rubocop/cop/rspec_rails Expand file tree Collapse file tree 3 files changed +11
-1
lines changed Original file line number Diff line number Diff line change 22
33## Master (Unreleased)
44
5+ - Fix a false positive for ` RspecRails/NegationBeValid ` when use ` to_not ` . ([ @ydah ] )
6+
57## 2.32.0 (2025-11-12)
68
79- Add ` RSpecRails/HttpStatusNameConsistency ` cop. ([ @taketo1113 ] )
Original file line number Diff line number Diff line change @@ -38,7 +38,7 @@ class NegationBeValid < ::RuboCop::Cop::Base
3838
3939 # @!method not_to?(node)
4040 def_node_matcher :not_to? , <<~PATTERN
41- (send ... :not_to (send nil? :be_valid ...))
41+ (send ... { :not_to :to_not} (send nil? :be_valid ...))
4242 PATTERN
4343
4444 # @!method be_invalid?(node)
Original file line number Diff line number Diff line change 4848 RUBY
4949 end
5050
51+ it 'registers an offense when using ' \
52+ '`expect(...).to_not be_valid`' do
53+ expect_offense ( <<~RUBY )
54+ expect(foo).to_not be_valid
55+ ^^^^^^^^^^^^^^^ Use `expect(...).to be_invalid`.
56+ RUBY
57+ end
58+
5159 it 'does not register an offense when using ' \
5260 '`expect(...).to be_invalid`' do
5361 expect_no_offenses ( <<~RUBY )
You can’t perform that action at this time.
0 commit comments