Skip to content

Commit

Permalink
chore: remove description requirement when creating an interaction
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewshirley committed Aug 30, 2021
1 parent 585eeea commit 29ce2d8
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 33 deletions.
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -22,7 +22,7 @@ import 'package:pact_dart/pact_dart.dart';
final pact = PactMockService('test-ffi-consumer','test-ffi-provider');
pact
.newInteraction('request for betsy')
.newInteraction()
.given('a alligator exists', params: { 'name': 'Betsy' })
.andGiven('the alligators were recently fed')
.uponReceiving('a request for an alligator')
Expand All @@ -45,7 +45,7 @@ pact.writePactFile(overwrite: true);

```dart
pact
.newInteraction('create an alligator')
.newInteraction()
.uponReceiving('a request to create an alligator named betsy')
.withRequest('POST', '/alligator', body: {
'alligator': {
Expand Down
2 changes: 1 addition & 1 deletion lib/src/pact_mock_service.dart
Expand Up @@ -48,7 +48,7 @@ class PactMockService {

/// Creates a new "Interaction" that describes the interaction
/// between the provider and consumer.
Interaction newInteraction(String description) {
Interaction newInteraction({String description = ''}) {
currentInteraction = Interaction(handle, description);
interactions.add(currentInteraction);

Expand Down
44 changes: 22 additions & 22 deletions test/integration/matchers_test.dart
Expand Up @@ -28,7 +28,7 @@ void main() {
};

pact
.newInteraction('create an alligator')
.newInteraction()
.uponReceiving('a request to create an alligator')
.withRequest('POST', '/alligator', body: requestBody)
.willRespondWith(201);
Expand Down Expand Up @@ -56,7 +56,7 @@ void main() {
};

pact
.newInteraction('create an alligator')
.newInteraction()
.uponReceiving('a request to create an alligator')
.withRequest('POST', '/alligator', body: requestBody)
.willRespondWith(201);
Expand Down Expand Up @@ -84,7 +84,7 @@ void main() {
};

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

pact
.newInteraction('update alligator contact email')
.newInteraction()
.uponReceiving('a request to update the alligators contact email')
.withRequest('PUT', '/alligator/1', body: requestBody)
.willRespondWith(204);
Expand All @@ -129,7 +129,7 @@ void main() {
test('should match when same types are used in the request body',
() async {
pact
.newInteraction('create an alligator')
.newInteraction()
.uponReceiving('a request to create an alligator named betsy')
.withRequest('POST', '/alligator', body: {
'alligator': {
Expand Down Expand Up @@ -163,7 +163,7 @@ void main() {
};

pact
.newInteraction('create an alligator')
.newInteraction()
.uponReceiving('a request to create an alligator')
.withRequest('GET', '/alligator', body: requestBody)
.willRespondWith(201);
Expand Down Expand Up @@ -195,7 +195,7 @@ void main() {
};

pact
.newInteraction('create alligators')
.newInteraction()
.uponReceiving('a request to create alligators')
.withRequest('POST', '/alligators', body: requestBody)
.willRespondWith(201);
Expand Down Expand Up @@ -227,7 +227,7 @@ void main() {
};

pact
.newInteraction('create alligators')
.newInteraction()
.uponReceiving('a request to create alligators')
.withRequest('POST', '/alligators', body: requestBody)
.willRespondWith(201);
Expand Down Expand Up @@ -260,7 +260,7 @@ void main() {
};

pact
.newInteraction('create alligators')
.newInteraction()
.uponReceiving('a request to create alligators')
.withRequest('POST', '/alligators', body: requestBody)
.willRespondWith(201);
Expand Down Expand Up @@ -291,7 +291,7 @@ void main() {
};

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

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

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

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

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

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

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

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

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

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

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

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

pact
.newInteraction('update alligator contact email')
.newInteraction()
.uponReceiving('a request to update the alligators id')
.withRequest('PUT', '/alligator/1', body: requestBody)
.willRespondWith(204);
Expand Down
16 changes: 8 additions & 8 deletions test/integration/pact_dart_test.dart
Expand Up @@ -24,7 +24,7 @@ void main() {
];

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

test('should add state params', () async {
pact
.newInteraction('request test')
.newInteraction()
.given('there is an alligator',
params: {'name': 'Betsy', 'hungry': 'true'})
.withRequest('GET', '/alligators')
Expand Down Expand Up @@ -88,7 +88,7 @@ void main() {
group('withRequest', () {
test('should match request with query param', () async {
pact
.newInteraction('query paramter test')
.newInteraction()
.withRequest('GET', '/alligator', query: {'hungry': 'true'});

pact.run(secure: false);
Expand All @@ -101,7 +101,7 @@ void main() {
});

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

Expand All @@ -116,7 +116,7 @@ void main() {

test('should match request with body', () async {
pact
.newInteraction('body test')
.newInteraction()
.withRequest('POST', '/alligator', body: {'name': 'Betsy'});

pact.run(secure: false);
Expand All @@ -134,7 +134,7 @@ void main() {
group('willRespondWith', () {
test('should respond to request', () async {
pact
.newInteraction('request test')
.newInteraction()
.withRequest('POST', '/alligator')
.willRespondWith(200);

Expand All @@ -149,7 +149,7 @@ void main() {

test('should respond with body', () async {
pact
.newInteraction('body test')
.newInteraction()
.withRequest('POST', '/alligator')
.willRespondWith(200, body: {'name': 'Betsy Jr.'});

Expand All @@ -164,7 +164,7 @@ void main() {

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

Expand Down

0 comments on commit 29ce2d8

Please sign in to comment.