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

Commit

Permalink
readme updates for jesus's comments
Browse files Browse the repository at this point in the history
  • Loading branch information
maxlinc committed Sep 23, 2013
1 parent 6b32bd1 commit ecfe3fa
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,21 +120,25 @@ to generate a valid JSON document as the response body, and relies on [WebMock](
to stub any HTTP requests made by your application. Important: the JSON generator is in very early stages and does not work
with the entire JSON Schema specification.

First, register the contracts that are going to be used in the acceptance tests suite:
First, register the contracts that are going to be used in the acceptance tests suite. The register_contract method accepts zero or more tags:
```ruby
require 'pacto'

contract = Pacto.build_from_file('/path/to/contract.json', 'http://dummyprovider.com')
Pacto.register_contract(contract, 'my_tag')
contract1 = Pacto.build_from_file('/path/to/contract1.json', 'http://dummyprovider.com')
contract2 = Pacto.build_from_file('/path/to/contract2.json', 'http://dummyprovider.com')
contract3 = Pacto.build_from_file('/path/to/contract3.json', 'http://dummyprovider.com')
Pacto.register_contract(contract1)
Pacto.register_contract(contract2, :public_api)
Pacto.register_contract(contract3, :public_api, :wip)
```
Then, in the setup phase of the test, specify which contracts will be used for that test:
```ruby
Pacto.use('my_tag')
Pacto.use('my_tag')
```
If default values are not specified in the contract's response body, a default value will be automatically generated. It is possible
to overwrite those values, however, by passing a second argument:
```ruby
Pacto.use('my_tag', :value => 'new value')
Pacto.use('my_tag', :value => 'new value')
```
The values are merged using [hash-deep-merge](https://github.com/Offirmo/hash-deep-merge).

Expand Down

0 comments on commit ecfe3fa

Please sign in to comment.