Sha256: c628c379ae664fea96dfa336717521992e50f11e7da5b0b018aa254b2f7cfff2
Contents?: true
Size: 1.26 KB
Versions: 3
Compression:
Stored size: 1.26 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_providers """ Given a file named "contracts/template.json" with: """json { "request": { "http_method": "GET", "path": "/hello", "headers": { "Accept": "application/json" }, "params": {} }, "response": { "status": 200, "headers": { "Content-Type": "application/json" }, "schema": { "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 stdout should contain: """ {"message":"!dlrow ,olleH"} """
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
pacto-0.4.0.rc3 | features/stub/templates.feature |
pacto-0.4.0.rc2 | features/stub/templates.feature |
pacto-0.4.0.rc1 | features/stub/templates.feature |