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: README.md
+11-10Lines changed: 11 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -156,24 +156,25 @@ as `generate`, in this case `2016-12-15T20:16:01`. When the contract is verified
156
156
provider, the regex will be used to search the response from the real provider service
157
157
and the test will be considered successful if the regex finds a match in the response.
158
158
159
-
### SomethingLike(matcher)
159
+
### Like(matcher)
160
160
Asserts the element's type matches the matcher. For example:
161
161
162
162
```python
163
-
from pact importSomethingLike
164
-
SomethingLike(123) # Matches if the value is an integer
165
-
SomethingLike('hello world') # Matches if the value is a string
166
-
SomethingLike(3.14) # Matches if the value is a float
163
+
from pact importLike
164
+
Like(123) # Matches if the value is an integer
165
+
Like('hello world') # Matches if the value is a string
166
+
Like(3.14) # Matches if the value is a float
167
167
```
168
-
The argument supplied to `SomethingLike` will be what the mock service responds with.
168
+
The argument supplied to `Like` will be what the mock service responds with.
169
169
170
-
When a dictionary is used as an argument for SomethingLike, all the child objects (and their child objects etc.) will be matched according to their types, unless you use a more specific matcher like a Term.
170
+
When a dictionary is used as an argument for Like, all the child objects (and their child objects etc.) will be matched according to their types, unless you use a more specific matcher like a Term.
171
171
172
172
```python
173
-
SomethingLike({
173
+
from pact import Like, Term
174
+
Like({
174
175
'username': Term('[a-zA-Z]+', 'username'),
175
176
'id': 123, # integer
176
-
'confirmed': false, # boolean
177
+
'confirmed': False, # boolean
177
178
'address': { # dictionary
178
179
'street': '200 Bourke St'# string
179
180
}
@@ -194,7 +195,7 @@ EachLike('hello') # All items are strings
194
195
Or other matchers can be nested inside to assert more complex objects:
0 commit comments