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
+44Lines changed: 44 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -157,6 +157,50 @@ For details of the implementation, see [matchers.rb](../lib/pact/v2/matchers.rb)
157
157
158
158
See the different uses of the matchers in [matchers_spec.rb](../spec/pact/v2/matchers_spec.rb)
159
159
160
+
### Generators
161
+
162
+
Generators are helper methods that allow you to specify dynamic values in your contract tests. These values are generated at runtime, making your contracts more flexible and robust. Below are the available generator methods:
163
+
164
+
For details of the implementation, see [matchers.rb](../lib/pact/v2/generators.rb)
165
+
166
+
-`generate_random_int(min:, max:)` - Generates a random integer between the specified `min` and `max`.
167
+
-`generate_random_decimal(digits:)` - Generates a random decimal number with the specified number of `digits`.
168
+
-`generate_random_hexadecimal(digits:)` - Generates a random hexadecimal string with the specified number of `digits`.
169
+
-`generate_random_string(size:)` - Generates a random string of the specified `size`.
170
+
-`generate_uuid(example: nil)` - Generates a random UUID. Optionally, provide an `example` value.
171
+
-`generate_date(format: nil, example: nil)` - Generates a date string in the specified `format`. Optionally, provide an `example`.
172
+
-`generate_time(format: nil)` - Generates a time string in the specified `format`.
173
+
-`generate_datetime(format: nil)` - Generates a datetime string in the specified `format`.
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`.
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
+
178
+
These generators can be used in your DSL definitions to provide dynamic values for requests, responses, or messages in your contract tests.
0 commit comments