spec/rubocop/cop/rspec/predicate_matcher_spec.rb in rubocop-rspec-1.30.1 vs spec/rubocop/cop/rspec/predicate_matcher_spec.rb in rubocop-rspec-1.31.0

- old
+ new

@@ -18,10 +18,19 @@ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Prefer using `be_empty` matcher over `empty?`. expect(foo.empty?).to_not be_truthy ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Prefer using `be_empty` matcher over `empty?`. expect(foo.empty?).to be_falsey ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Prefer using `be_empty` matcher over `empty?`. + RUBY + end + + it 'registers an offense for a predicate method with built-in equiv' do + expect_offense(<<-RUBY) + expect(foo.exist?).to be_truthy + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Prefer using `exist` matcher over `exist?`. + expect(foo.exists?).to be_truthy + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Prefer using `exist` matcher over `exists?`. expect(foo.has_something?).to be_truthy ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Prefer using `have_something` matcher over `has_something?`. expect(foo.include?(something)).to be_truthy ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Prefer using `include` matcher over `include?`. expect(foo.respond_to?(:bar)).to be_truthy @@ -104,10 +113,13 @@ 'expect(foo.include?(something)).to be_truthy', 'expect(foo).to include(something)' include_examples 'autocorrect', 'expect(foo.respond_to?(:bar)).to be_truthy', 'expect(foo).to respond_to(:bar)' + include_examples 'autocorrect', + 'expect(foo.exists?).to be_truthy', + 'expect(foo).to exist' include_examples 'autocorrect', 'expect(foo.something?()).to be_truthy', 'expect(foo).to be_something()' include_examples 'autocorrect', @@ -250,9 +262,10 @@ expect(foo).to be_falsy expect(foo).to have_attributes(name: 'foo') expect(foo).to have_received(:foo) expect(foo).to be_between(1, 10) expect(foo).to be_within(0.1).of(10.0) + expect(foo).to exist RUBY end it 'accepts non-predicate matcher' do expect_no_offenses(<<-RUBY)