Skip to content

Commit 29ce2d8

Browse files
chore: remove description requirement when creating an interaction
1 parent 585eeea commit 29ce2d8

File tree

4 files changed

+33
-33
lines changed

4 files changed

+33
-33
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import 'package:pact_dart/pact_dart.dart';
2222
final pact = PactMockService('test-ffi-consumer','test-ffi-provider');
2323
2424
pact
25-
.newInteraction('request for betsy')
25+
.newInteraction()
2626
.given('a alligator exists', params: { 'name': 'Betsy' })
2727
.andGiven('the alligators were recently fed')
2828
.uponReceiving('a request for an alligator')
@@ -45,7 +45,7 @@ pact.writePactFile(overwrite: true);
4545

4646
```dart
4747
pact
48-
.newInteraction('create an alligator')
48+
.newInteraction()
4949
.uponReceiving('a request to create an alligator named betsy')
5050
.withRequest('POST', '/alligator', body: {
5151
'alligator': {

lib/src/pact_mock_service.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class PactMockService {
4848

4949
/// Creates a new "Interaction" that describes the interaction
5050
/// between the provider and consumer.
51-
Interaction newInteraction(String description) {
51+
Interaction newInteraction({String description = ''}) {
5252
currentInteraction = Interaction(handle, description);
5353
interactions.add(currentInteraction);
5454

test/integration/matchers_test.dart

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ void main() {
2828
};
2929

3030
pact
31-
.newInteraction('create an alligator')
31+
.newInteraction()
3232
.uponReceiving('a request to create an alligator')
3333
.withRequest('POST', '/alligator', body: requestBody)
3434
.willRespondWith(201);
@@ -56,7 +56,7 @@ void main() {
5656
};
5757

5858
pact
59-
.newInteraction('create an alligator')
59+
.newInteraction()
6060
.uponReceiving('a request to create an alligator')
6161
.withRequest('POST', '/alligator', body: requestBody)
6262
.willRespondWith(201);
@@ -84,7 +84,7 @@ void main() {
8484
};
8585

8686
pact
87-
.newInteraction('update alligator contact email')
87+
.newInteraction()
8888
.uponReceiving('a request to update the alligators contact email')
8989
.withRequest('PUT', '/alligator/1', body: requestBody)
9090
.willRespondWith(204);
@@ -109,7 +109,7 @@ void main() {
109109
};
110110

111111
pact
112-
.newInteraction('update alligator contact email')
112+
.newInteraction()
113113
.uponReceiving('a request to update the alligators contact email')
114114
.withRequest('PUT', '/alligator/1', body: requestBody)
115115
.willRespondWith(204);
@@ -129,7 +129,7 @@ void main() {
129129
test('should match when same types are used in the request body',
130130
() async {
131131
pact
132-
.newInteraction('create an alligator')
132+
.newInteraction()
133133
.uponReceiving('a request to create an alligator named betsy')
134134
.withRequest('POST', '/alligator', body: {
135135
'alligator': {
@@ -163,7 +163,7 @@ void main() {
163163
};
164164

165165
pact
166-
.newInteraction('create an alligator')
166+
.newInteraction()
167167
.uponReceiving('a request to create an alligator')
168168
.withRequest('GET', '/alligator', body: requestBody)
169169
.willRespondWith(201);
@@ -195,7 +195,7 @@ void main() {
195195
};
196196

197197
pact
198-
.newInteraction('create alligators')
198+
.newInteraction()
199199
.uponReceiving('a request to create alligators')
200200
.withRequest('POST', '/alligators', body: requestBody)
201201
.willRespondWith(201);
@@ -227,7 +227,7 @@ void main() {
227227
};
228228

229229
pact
230-
.newInteraction('create alligators')
230+
.newInteraction()
231231
.uponReceiving('a request to create alligators')
232232
.withRequest('POST', '/alligators', body: requestBody)
233233
.willRespondWith(201);
@@ -260,7 +260,7 @@ void main() {
260260
};
261261

262262
pact
263-
.newInteraction('create alligators')
263+
.newInteraction()
264264
.uponReceiving('a request to create alligators')
265265
.withRequest('POST', '/alligators', body: requestBody)
266266
.willRespondWith(201);
@@ -291,7 +291,7 @@ void main() {
291291
};
292292

293293
pact
294-
.newInteraction('create alligators')
294+
.newInteraction()
295295
.uponReceiving('a request to create alligators')
296296
.withRequest('POST', '/alligators', body: requestBody)
297297
.willRespondWith(201);
@@ -317,7 +317,7 @@ void main() {
317317
final requestBody = {'numberOfTeeth': PactMatchers.IntegerLike(80)};
318318

319319
pact
320-
.newInteraction('update alligator teeth count')
320+
.newInteraction()
321321
.uponReceiving('a request to update betsy\'s number of teeth')
322322
.withRequest('PUT', '/alligators/1/teeth', body: requestBody)
323323
.willRespondWith(204);
@@ -337,7 +337,7 @@ void main() {
337337
final requestBody = {'numberOfTeeth': PactMatchers.IntegerLike(80)};
338338

339339
pact
340-
.newInteraction('update alligator teeth count')
340+
.newInteraction()
341341
.uponReceiving('a request to update betsy\'s number of teeth')
342342
.withRequest('PUT', '/alligators/1/teeth', body: requestBody)
343343
.willRespondWith(204);
@@ -360,7 +360,7 @@ void main() {
360360
};
361361

362362
pact
363-
.newInteraction('update alligator accident count')
363+
.newInteraction()
364364
.uponReceiving('a request to update betsy\'s accident count')
365365
.withRequest('PUT', '/alligators/1/accidents', body: requestBody)
366366
.willRespondWith(204);
@@ -382,7 +382,7 @@ void main() {
382382
};
383383

384384
pact
385-
.newInteraction('update alligator accident count')
385+
.newInteraction()
386386
.uponReceiving('a request to update betsy\'s accident count')
387387
.withRequest('PUT', '/alligators/1/accidents', body: requestBody)
388388
.willRespondWith(204);
@@ -403,7 +403,7 @@ void main() {
403403
final requestBody = {'favouriteFood': PactMatchers.Null()};
404404

405405
pact
406-
.newInteraction('update alligator favourite food')
406+
.newInteraction()
407407
.uponReceiving('a request to update betsy\'s favourite food')
408408
.withRequest('PUT', '/alligators/1/metadata', body: requestBody)
409409
.willRespondWith(204);
@@ -423,7 +423,7 @@ void main() {
423423
final requestBody = {'favouriteFood': PactMatchers.Null()};
424424

425425
pact
426-
.newInteraction('update alligator favourite food')
426+
.newInteraction()
427427
.uponReceiving('a request to update betsy\'s favourite food')
428428
.withRequest('PUT', '/alligators/1/metadata', body: requestBody)
429429
.willRespondWith(204);
@@ -449,7 +449,7 @@ void main() {
449449
};
450450

451451
pact
452-
.newInteraction('update alligator favourite food')
452+
.newInteraction()
453453
.uponReceiving('a request to update betsy\'s favourite food')
454454
.withRequest('PUT', '/alligators/1/metadata', body: requestBody)
455455
.willRespondWith(204);
@@ -473,7 +473,7 @@ void main() {
473473
};
474474

475475
pact
476-
.newInteraction('update alligator favourite food')
476+
.newInteraction()
477477
.uponReceiving('a request to update betsy\'s favourite food')
478478
.withRequest('PUT', '/alligators/1/metadata', body: requestBody)
479479
.willRespondWith(204);
@@ -499,7 +499,7 @@ void main() {
499499
};
500500

501501
pact
502-
.newInteraction('update alligator contact email')
502+
.newInteraction()
503503
.uponReceiving('a request to update the alligators contact email')
504504
.withRequest('PUT', '/alligator/1', body: requestBody)
505505
.willRespondWith(204);
@@ -522,7 +522,7 @@ void main() {
522522
};
523523

524524
pact
525-
.newInteraction('update alligator contact email')
525+
.newInteraction()
526526
.uponReceiving('a request to update the alligators contact email')
527527
.withRequest('PUT', '/alligator/1', body: requestBody)
528528
.willRespondWith(204);
@@ -546,7 +546,7 @@ void main() {
546546
};
547547

548548
pact
549-
.newInteraction('update alligator contact email')
549+
.newInteraction()
550550
.uponReceiving('a request to update the alligators id')
551551
.withRequest('PUT', '/alligator/1', body: requestBody)
552552
.willRespondWith(204);
@@ -570,7 +570,7 @@ void main() {
570570
};
571571

572572
pact
573-
.newInteraction('update alligator contact email')
573+
.newInteraction()
574574
.uponReceiving('a request to update the alligators id')
575575
.withRequest('PUT', '/alligator/1', body: requestBody)
576576
.willRespondWith(204);

test/integration/pact_dart_test.dart

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ void main() {
2424
];
2525

2626
pact
27-
.newInteraction('request test')
27+
.newInteraction()
2828
.given('there is an alligator named betsy')
2929
.andGiven('the alligators were recently fed')
3030
.withRequest('GET', '/alligators')
@@ -51,7 +51,7 @@ void main() {
5151

5252
test('should add state params', () async {
5353
pact
54-
.newInteraction('request test')
54+
.newInteraction()
5555
.given('there is an alligator',
5656
params: {'name': 'Betsy', 'hungry': 'true'})
5757
.withRequest('GET', '/alligators')
@@ -88,7 +88,7 @@ void main() {
8888
group('withRequest', () {
8989
test('should match request with query param', () async {
9090
pact
91-
.newInteraction('query paramter test')
91+
.newInteraction()
9292
.withRequest('GET', '/alligator', query: {'hungry': 'true'});
9393

9494
pact.run(secure: false);
@@ -101,7 +101,7 @@ void main() {
101101
});
102102

103103
test('should match request with headers', () async {
104-
pact.newInteraction('header paramter test').withRequest(
104+
pact.newInteraction()
105105
'GET', '/alligator',
106106
headers: {'X-ALLIGATOR-LAST-FED': 'Yesterday'});
107107

@@ -116,7 +116,7 @@ void main() {
116116

117117
test('should match request with body', () async {
118118
pact
119-
.newInteraction('body test')
119+
.newInteraction()
120120
.withRequest('POST', '/alligator', body: {'name': 'Betsy'});
121121

122122
pact.run(secure: false);
@@ -134,7 +134,7 @@ void main() {
134134
group('willRespondWith', () {
135135
test('should respond to request', () async {
136136
pact
137-
.newInteraction('request test')
137+
.newInteraction()
138138
.withRequest('POST', '/alligator')
139139
.willRespondWith(200);
140140

@@ -149,7 +149,7 @@ void main() {
149149

150150
test('should respond with body', () async {
151151
pact
152-
.newInteraction('body test')
152+
.newInteraction()
153153
.withRequest('POST', '/alligator')
154154
.willRespondWith(200, body: {'name': 'Betsy Jr.'});
155155

@@ -164,7 +164,7 @@ void main() {
164164

165165
test('should respond with header', () async {
166166
pact
167-
.newInteraction('header test')
167+
.newInteraction()
168168
.withRequest('POST', '/alligator')
169169
.willRespondWith(200, headers: {'X-ALLIGATOR-IS-HUNGRY': 'No'});
170170

0 commit comments

Comments
 (0)