Sha256: 7a097534f2f49707e13afa3c9e77b131e416e9f5cbf9db5158e8dcaf7f05e9dd
Contents?: true
Size: 1.25 KB
Versions: 2
Compression:
Stored size: 1.25 KB
Contents
Feature: Templating If you want to create more dynamic stubs, you can use Pacto templating. Currently the only supported templating mechanism is to use ERB in the "default" attributes of the json-schema. Background: Given Pacto is configured with: """ruby Pacto.configure do |c| c.register_hook Pacto::Hooks::ERBHook.new end Pacto.load_contracts('contracts', 'http://example.com').stub_all """ Given a file named "contracts/template.json" with: """json { "request": { "method": "GET", "path": "/hello", "headers": { "Accept": "application/json" }, "params": {} }, "response": { "status": 200, "headers": { "Content-Type": "application/json" }, "body": { "type": "object", "required": true, "properties": { "message": { "type": "string", "required": true, "default": "<%= 'Hello, world!'.reverse %>" } } } } } """ Scenario: ERB Template When I request "http://example.com/hello" Then the output should contain: """ {"message":"!dlrow ,olleH"} """
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
pacto-0.3.1 | features/stub/templates.feature |
pacto-0.3.0 | features/stub/templates.feature |