Skip to content
This repository has been archived by the owner on Dec 5, 2019. It is now read-only.

Generation hints #135

Merged
merged 8 commits into from
Sep 26, 2014
Merged

Generation hints #135

merged 8 commits into from
Sep 26, 2014

Conversation

maxlinc
Copy link
Collaborator

@maxlinc maxlinc commented Jul 14, 2014

I've added a generation hint system to improve generating contracts. I'm just finishing up a sample. Here's what the docs from the sample will contain:

You can provide hints to Pacto to help it generate contracts. For example, Pacto doesn't have
a good way to know a good name and correct URI template for the service. That means that Pacto
will not know if two similar requests are for the same service or two different services, and
will be forced to give names based on the URI that are not good display names.

The hint below tells Pacto that requests to http://localhost:5000/album/1/cover and http://localhost:5000/album/2/cover
are both going to the same service, which is known as "Get Album Cover". This hint will cause Pacto to
generate a Contract for "Get Album Cover" and save it to contracts/get_album_cover.json, rather than two
contracts that are stored at contracts/localhost/album/1/cover.json and contracts/localhost/album/2/cover.json.

Pacto::Generator.configure do |c|
  c.hint 'Get Album Cover', http_method: :get, host: 'http://localhost:5000', path: '/album/{id}/cover'
end
conn.get '/api/album/1/cover'
conn.get '/api/album/2/cover'

@coveralls
Copy link

Coverage Status

Coverage decreased (-5.37%) when pulling 24e68ff on builder into bfc0016 on master.

@coveralls
Copy link

Coverage Status

Coverage increased (+1.82%) when pulling e48397c on builder into bfc0016 on master.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants