You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: documentation/README_V2.md
+18-9Lines changed: 18 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -172,14 +172,23 @@ For details of the implementation, see [matchers.rb](../lib/pact/v2/generators.r
172
172
-`generate_time(format: nil)` - Generates a time string in the specified `format`.
173
173
-`generate_datetime(format: nil)` - Generates a datetime string in the specified `format`.
174
174
-`generate_random_boolean` - Generates a random boolean value (`true` or `false`).
175
-
-`generate_from_provider_state(expression:)` - Generates a value from the provider state using the given `expression`.
175
+
-`generate_from_provider_state(expression:, example:)` - Generates a value from the provider state using the given `expression` and `example` value. Allows templating of url and query paths with values only know at provider verification time.
176
176
-`generate_mock_server_url(regex: nil, example: nil)` - Generates a mock server URL. Optionally, specify a `regex` matches and/or an `example` value.
177
177
178
178
These generators can be used in your DSL definitions to provide dynamic values for requests, responses, or messages in your contract tests.
179
179
180
180
#### Generator Examples
181
181
182
182
```rb
183
+
.with_request(
184
+
method::get,
185
+
path: generate_from_provider_state(
186
+
expression:'/alligators/${alligator_name}',
187
+
example:'/alligators/Mary'),
188
+
headers: headers)
189
+
190
+
...
191
+
183
192
body: {
184
193
_links: {
185
194
:'pf:publish-provider-contract' => {
@@ -433,30 +442,30 @@ The following projects were designed for pact-ruby-v1 and have been migrated to
0 commit comments