features/generate/generation.feature in pacto-0.4.0.rc1 vs features/generate/generation.feature in pacto-0.4.0.rc2
- old
+ new
@@ -8,14 +8,14 @@
Remember, we only record request headers if they are in the response's [Vary header](http://www.subbu.org/blog/2007/12/vary-header-for-restful-applications), so make sure your services return a proper Vary for best results!
Background:
Given a file named "requests/my_contract.json" with:
"""
- {
+ {
"request": {
"http_method": "GET",
- "path": "/hello",
+ "path": "/api/ping",
"headers": {
"Accept": "application/json"
}
},
"response": {
@@ -27,48 +27,46 @@
}
"""
Scenario: Generating a contract using the rake task
Given a directory named "contracts"
- When I successfully run `bundle exec rake pacto:generate['tmp/aruba/requests','tmp/aruba/contracts','http://localhost:8000']`
+ When I successfully run `bundle exec rake pacto:generate['tmp/aruba/requests','tmp/aruba/contracts','http://localhost:5000']`
Then the stdout should contain "Successfully generated all contracts"
Scenario: Generating a contract programmatically
Given a file named "generate.rb" with:
"""ruby
require 'pacto'
Pacto.configuration.generator_options[:no_examples] = true
WebMock.allow_net_connect!
generator = Pacto::Generator.contract_generator
- contract = generator.generate_from_partial_contract('requests/my_contract.json', 'http://localhost:8000')
+ contract = generator.generate_from_partial_contract('requests/my_contract.json', 'http://localhost:5000')
puts contract
"""
When I successfully run `bundle exec ruby generate.rb`
Then the stdout should match this contract:
"""json
{
- "name": "/hello",
+ "name": "/api/ping",
"request": {
"headers": {
- "Accept": "application/json"
},
"http_method": "get",
- "path": "/hello"
+ "path": "/api/ping"
},
"response": {
"headers": {
- "Content-Type": "application/json",
- "Vary": "Accept"
+ "Content-Type": "application/json"
},
"status": 200,
"schema": {
"$schema": "http://json-schema.org/draft-03/schema#",
"description": "Generated from requests/my_contract.json with shasum 210fa3b144ef2db8d1c160c4d9e8d8bf738ed851",
"type": "object",
"required": true,
"properties": {
- "message": {
+ "ping": {
"type": "string",
"required": true
}
}
}