title: How to test a method is invoked after other in an object?
body: <p>I have the following class:</p>
  
  <pre><code>class Foo
    def initialize(foobar:)
      @foobar = foobar
    end
  
    def call
      return if foobar.blank?
      do_something_here
    end
  end
  </code></pre>
  
  <p>Which is being invoked in an after_commit callback from a model:</p>
  
  <pre><code>included { after_commit :invoke_method_in_poro, on: %I[create update] }
  
  private
  
  def invoke_method_in_poro
    Foo.new(foobar: to_json).call
  end
  </code></pre>
  
  <p>Now when I try to test if <code>call</code> is being invoked, I need to first stub the new method, because I'm getting this error:</p>
  
  <pre><code>NameError: undefined method `call' for class `Foo'
  Did you mean?  caller
  </code></pre>
  
  <p>With this code:</p>
  
  <pre><code>foo = Foo
  new_mock = Minitest::Mock.new
  new_mock.expect :call, nil
  foo.stub(:call, new_mock) do
    create(:model)
  end
  mock.verify
  </code></pre>
  
  <p>My question is, how finally can I test that <code>call</code> is being invoked?</p>