Skip to content

Commit 5de7200

Browse files
authored
Merge pull request #49 from pact-foundation/rename-somethinglike
Resolve #43: Rename SomethingLike to Like
2 parents a07c8b6 + d73aa1c commit 5de7200

File tree

4 files changed

+26
-15
lines changed

4 files changed

+26
-15
lines changed

README.md

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -156,24 +156,25 @@ as `generate`, in this case `2016-12-15T20:16:01`. When the contract is verified
156156
provider, the regex will be used to search the response from the real provider service
157157
and the test will be considered successful if the regex finds a match in the response.
158158

159-
### SomethingLike(matcher)
159+
### Like(matcher)
160160
Asserts the element's type matches the matcher. For example:
161161

162162
```python
163-
from pact import SomethingLike
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 import Like
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
167167
```
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.
169169

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.
171171

172172
```python
173-
SomethingLike({
173+
from pact import Like, Term
174+
Like({
174175
'username': Term('[a-zA-Z]+', 'username'),
175176
'id': 123, # integer
176-
'confirmed': false, # boolean
177+
'confirmed': False, # boolean
177178
'address': { # dictionary
178179
'street': '200 Bourke St' # string
179180
}
@@ -194,7 +195,7 @@ EachLike('hello') # All items are strings
194195
Or other matchers can be nested inside to assert more complex objects:
195196

196197
```python
197-
from pact import EachLike, SomethingLike, Term
198+
from pact import EachLike, Term
198199
EachLike({
199200
'username': Term('[a-zA-Z]+', 'username'),
200201
'id': 123,

pact/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
"""Python methods for interactive with a Pact Mock Service."""
22
from .consumer import Consumer
3-
from .matchers import EachLike, SomethingLike, Term
3+
from .matchers import EachLike, Like, SomethingLike, Term
44
from .pact import Pact
55
from .provider import Provider
66
from .__version__ import __version__ # noqa: F401
77

8-
__all__ = ('Consumer', 'EachLike', 'Pact', 'Provider', 'SomethingLike', 'Term')
8+
__all__ = ('Consumer', 'EachLike', 'Like', 'Pact', 'Provider', 'SomethingLike',
9+
'Term')

pact/matchers.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def generate(self):
6666
'min': self.minimum}
6767

6868

69-
class SomethingLike(Matcher):
69+
class Like(Matcher):
7070
"""
7171
Expect the type of the value to be the same as matcher.
7272
@@ -79,7 +79,7 @@ class SomethingLike(Matcher):
7979
... .upon_receiving('a request for a random number')
8080
... .with_request('get', '/generate-number')
8181
... .will_respond_with(200, body={
82-
... 'number': SomethingLike(1111222233334444)
82+
... 'number': Like(1111222233334444)
8383
... }))
8484
8585
Would expect the response body to be a JSON object, containing the key
@@ -120,6 +120,10 @@ def generate(self):
120120
'contents': from_term(self.matcher)}
121121

122122

123+
# Remove SomethingLike in major version 1.0.0
124+
SomethingLike = Like
125+
126+
123127
class Term(Matcher):
124128
"""
125129
Expect the response to match a specified regular expression.

pact/test/test_matchers.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from unittest import TestCase
22

3-
from ..matchers import EachLike, Matcher, SomethingLike, Term, from_term
3+
from ..matchers import EachLike, Like, Matcher, SomethingLike, Term, from_term
44

55

66
class MatcherTestCase(TestCase):
@@ -56,6 +56,11 @@ def test_nested_matchers(self):
5656
'min': 1})
5757

5858

59+
class LikeTestCase(TestCase):
60+
def test_is_something_like(self):
61+
self.assertIs(SomethingLike, Like)
62+
63+
5964
class SomethingLikeTestCase(TestCase):
6065
def test_valid_types(self):
6166
types = [None, list(), dict(), 1, 1.0, 'string', u'unicode', Matcher()]

0 commit comments

Comments
 (0)