pact-foundation / pact-ruby

Enables consumer driven contract testing, providing a mock service and DSL for the consumer project, and interaction playback and verification for the service provider project.
https://pact.io
MIT License
2.17k stars 216 forks source link

Set order of interactions in Pact file #279

Closed patrickbadleyupstart closed 2 years ago

patrickbadleyupstart commented 2 years ago

This is a duplicate of an old issue that was marked as resolved and closed, but I am still seeing this behavior. When I run my rspec tests for my consumer the generated pactfile will intermittently get written with it's interactions in a different order. This makes for confusing git change history. Is it possible that the interaction ordering was broken somehow? I'm not sure what the best solution would be, but perhaps ordering interactions by description and then provider state?

Gem versions:

    pact (1.63.0)
      pact-mock_service (~> 3.0, >= 3.3.1)
      pact-support (~> 1.16, >= 1.16.9)
      rack-test (>= 0.6.3, < 3.0.0)
      rspec (~> 3.0)
      term-ansicolor (~> 1.0)
      thor (>= 0.20, < 2.0)
      webrick (~> 1.3)
bethesque commented 2 years ago

You can set the order to alphabetical https://github.com/pact-foundation/pact-mock_service/blob/master/lib/pact/consumer_contract/consumer_contract_decorator.rb#L33

patrickbadleyupstart commented 2 years ago

Thank you!