title: How to assert that a method call was not made, without any_instance?
body: <p>I have a class, that in one situation should call <code>:my_method</code>, but in another situation must not call method <code>:my_method</code>. I would like to test both cases. Also, I would like the test to document the cases when <code>:my_method</code> should not be called.</p>
  
  <p><a href="https://relishapp.com/rspec/rspec-mocks/docs/working-with-legacy-code/any-instance" rel="noreferrer">Using <code>any_instance</code> is generally discouraged</a>, so I would be happy to learn a nice way to replace it.</p>
  
  <p>This code snippet is a reduced example on what I kind of test I would like to write.</p>
  
  <pre><code>class TestSubject
    def call
      call_me
    end
  
     def call_me; end
     def never_mind; end
  end
  
  require 'rspec'
  
  spec = RSpec.describe 'TestSubject' do
    describe '#call' do
      it 'calls #call_me' do
        expect_any_instance_of(TestSubject).to receive(:call_me)
        TestSubject.new.call
      end
  
      it 'does not call #never_mind' do
        expect_any_instance_of(TestSubject).not_to receive(:never_mind)
        TestSubject.new.call
      end
    end
  end
  
  spec.run # =&gt; true
  </code></pre>
  
  <p>It works, but uses  <code>expect_any_instance_of</code> method, which is not recommended. </p>
  
  <p>How to replace it?</p>