title: How to test an Interactor Organizer with Minitest
body: <p>First off, I am using the <a href="https://github.com/collectiveidea/interactor" rel="nofollow noreferrer">Interactor Gem</a>. (You should check it out if you haven't. Pretty cool lib)</p>
  
  <p>Let's say I've got an Interactor::Organizer as follows:</p>
  
  <pre><code>class InitiateImport
    include Interactor::Organizer
  
    organize CreateImport, QueueImport
  end
  </code></pre>
  
  <p>And I've also got two Interactors as follows:</p>
  
  <pre><code>class CreateImport
    include Interactor
  
    def call
      import = Import.create()
      if import
        context.import = import
      else
         context.fail!(message: 'import failed!')
      end
    end
  end
  </code></pre>
  
  <p>and </p>
  
  <pre><code>class QueueImport
    include Interactor
  
    def call
      unless QueueHandler.perform_later(context.import.id)
        context.fail!(message: 'Queue broke!')
      end
    end
  end
  </code></pre>
  
  <p><strong>BIG QUESTION</strong> - How do I -- using Minitest -- test that <code>organize</code> is being called on <code>InitiateImport</code> with the argument <code>[CreateImport, QueueImport]</code></p>
  
  <p><a href="http://ruby-doc.org/stdlib-2.0.0/libdoc/minitest/rdoc/MiniTest/Assertions.html#method-i-assert_send" rel="nofollow noreferrer"><code>assert_send</code></a> will let me verify that <code>organize</code> is being called, but it won't let me verify what arguments I pass it. Something like this:</p>
  
  <pre><code>class InitiateImportTest &lt; Minitest::Test  
    def test_organize_called
      InitiateImport.new(file: file)
  
      assert_send([InitiateImport, :organize, [CreateImport, QueueImport]])
    end
  end
  </code></pre>
  
  <p>I found <a href="https://stackoverflow.com/questions/10869417/how-to-assert-certain-method-is-called-with-ruby-minitest-framework">this</a> question / answer from nearly 3 years ago, but it didn't provide much clarity for me. Maybe it's in there and I'm just missing something?</p>
  
  <p>I also realize that I could just <code>call</code> the organizer with valid param data such that it passes and I verify the output from there, however I've already got those two classes under test and I'd basically just be exercising the same functionality twice. I'd really like to just verify method invocation and arguments if possible.</p>
  
  <p>Any help or suggestions would be greatly appreciated.</p>