title: With rspec how do I test a method received a hash parameter in the correct order?
body: <p>Unfortunately I'm needing to interact with a Soap API. If that's not bad enough, the API has parameter ordering turned on which means, regardless of the fact it's XML, it must be structured in the correct element order. </p>
  
  <p>I'm using Savon so I'm building an ordered hash. However after some refactoring, the real calls stopped working whilst all my tests continued to pass. A typical test looks like this:</p>
  
  <pre><code>it 'should receive correctly ordered hash' do
    example_id = 12345789
    our_api = Example::ApiGateway.new()
    params = {:message=&gt;{'ApiKey' =&gt; api_key, 'ExampleId' =&gt; example_id}}
    Savon::Client.any_instance.should_receive(:call).with(:get_user_details, params).and_return(mocked_response())
    our_api.get_user(example_id: example_id)
  end
  </code></pre>
  
  <p>The hash compare totally does not care about the order of the keys so this test passes regardless of the actual hash order received. I'd like the just grab the parameters that the <code>call</code> method receives and then I could compare the ordered keys of each hash but I con't find how to do this.</p>
  
  <p>How do I make sure that the Savon call receives the message hash in the correct order?</p>