title: How do I test the order of method calls in rspec?
body: <p>I have a class that uses the command pattern to do a bunch of simple transformation steps in order. Data comes in as a data feed (in XML) and then is transformed through multiple steps using single-purpose step classes. So it might look like this (actual class names are different):</p>
  
  <pre><code>raw_data = Downloader.new(feed)
  parsed_data = Parser.new(raw_data)
  translated_data = Translator.new(parsed_data)
  sifted_data = Sifter.new(translated_data)
  collate_data = Collator.new(sifted_data)
  </code></pre>
  
  <p>etc.</p>
  
  <p>I have unit tests for each class, and I have integration tests to verify the full flow, including that each class is called.</p>
  
  <p><strong>But I don't have any way to test the order they are called</strong></p>
  
  <p>I'd like some test so I can know: the Downloader is called first, then the Parser, then the Translator, etc.</p>
  
  <p>This is in Ruby with Rspec 3.</p>
  
  <p>I did find this: <a href="http://testpractices.blogspot.com/2008/07/ordered-method-testing-with-rspec.html" rel="noreferrer">http://testpractices.blogspot.com/2008/07/ordered-method-testing-with-rspec.html</a> but this is from 2008 and it's also really ugly. Is there a better way to test method execution order?</p>
  
  <p>Thanks!</p>