pact-ruby icon indicating copy to clipboard operation
pact-ruby copied to clipboard

Improve Pact specification compliance spec

Open tancnle opened this issue 8 years ago • 1 comments

Why

Provide better guidance on future specification upgrades.

What

Running rspec spec/pact_specification/compliance-1.0.0.rb with pact-specification repo checked out in certain version throws exception and short circuit all other tests.

# With v1
KeyError: key not found: :method
  /Users/tanle/.gem/ruby/2.2.3/gems/pact-support-0.6.0/lib/pact/consumer_contract/request.rb:15:in `fetch'
  /Users/tanle/.gem/ruby/2.2.3/gems/pact-support-0.6.0/lib/pact/consumer_contract/request.rb:15:in `from_hash'
  /Users/tanle/works/open-source/pact/spec/pact_specification/compliance-1.0.0.rb:27:in `block (7 levels) in <top (required)>'
  /Users/tanle/.gem/ruby/2.2.3/gems/rspec-core-3.5.4/lib/rspec/core/example_group.rb:385:in `module_exec'
  /Users/tanle/.gem/ruby/2.2.3/gems/rspec-core-3.5.4/lib/rspec/core/example_group.rb:385:in `subclass'
  /Users/tanle/.gem/ruby/2.2.3/gems/rspec-core-3.5.4/lib/rspec/core/example_group.rb:258:in `block in define_example_group_method'
  /Users/tanle/works/open-source/pact/spec/pact_specification/compliance-1.0.0.rb:25:in `block (6 levels) in <top (required)>'
...

# With v2
KeyError: key not found: :headers
  /Users/tanle/.gem/ruby/2.2.3/gems/pact-support-0.6.0/lib/pact/consumer/request.rb:14:in `fetch'
  /Users/tanle/.gem/ruby/2.2.3/gems/pact-support-0.6.0/lib/pact/consumer/request.rb:14:in `from_hash'
  /Users/tanle/works/open-source/pact/spec/pact_specification/compliance-1.0.0.rb:28:in `block (7 levels) in <top (required)>'
  /Users/tanle/.gem/ruby/2.2.3/gems/rspec-core-3.5.4/lib/rspec/core/example_group.rb:385:in `module_exec'
  /Users/tanle/.gem/ruby/2.2.3/gems/rspec-core-3.5.4/lib/rspec/core/example_group.rb:385:in `subclass'
  /Users/tanle/.gem/ruby/2.2.3/gems/rspec-core-3.5.4/lib/rspec/core/example_group.rb:258:in `block in define_example_group_method'
  /Users/tanle/works/open-source/pact/spec/pact_specification/compliance-1.0.0.rb:25:in `block (6 levels) in <top (required)>'
...

How

  • Gracefully handle exception case, fail the test and continue on.
  • Loop through those failed test cases and confirm whether those are legitimate non-compliance failures or incorrect specification test cases.

tancnle avatar Jan 27 '17 12:01 tancnle

👍

bethesque avatar Jan 29 '17 22:01 bethesque

We've since created a pact-compatibility-suite with the intention that it can be validated across languages.

It's implementation will be tracked against these tickets

  • https://github.com/pact-foundation/pact-ruby/issues/317
  • https://github.com/pact-foundation/pact-ruby/issues/318
  • https://github.com/pact-foundation/pact-ruby/issues/319

So work should be considered to deprecate this compliance suite from the project (it currently doesn't run as part of the tests)

note the file resides here

edit: I've now raised a separate ticket to track the implementation of the compat-suite so will close off this ticket, thanks!

YOU54F avatar Aug 15 '24 15:08 YOU54F