thoughtworks / pacto

Pacto settles disputes between JSON providers and consumers
thoughtworks.github.io/pacto
MIT License
401 stars 58 forks source link

request_clause headers need default value #166

Closed fishermand46 closed 9 years ago

fishermand46 commented 9 years ago

I'm getting lib/pacto/stubs/webmock_adapter.rb:95:inblock in strict_details': undefined method empty?' for nil:NilClass (NoMethodError) when I try to stub_providers with pacto. I tracked it down to the request_clause.headers being nil.

Test code:

contracts = Pacto.load_contracts('spec/fixtures', 'http://localhost:3000', :swagger)
contracts.stub_providers

Here you can see that headers in request_clause has no default value. But in the response clause, headers defaults to {}. I think it should in request_clause as well.

maxlinc commented 9 years ago

It makes sense, except that I would like to get away from RequestClause having attributes at all, so that it just an interface that should be implemented by subclasses for specific contract formats (Swagger, RAML, whatever).

I guess I need to find time to make RequestClause abstract and create a subclass for LegacyRequestClause.

fishermand46 commented 9 years ago

That sounds like a good direction to move. :thumbsup: