Skip to content

Commit 5e805e5

Browse files
committed
Merge branch 'release/3.2.1'
2 parents 827d8dc + a284057 commit 5e805e5

17 files changed

+858
-363
lines changed

CHANGELOG.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,23 @@
11
# Changelog
22

3+
## [3.2.1](https://github.com/appercept/Delphi-WebMocks/tree/3.2.1) (2024-04-18)
4+
5+
[Full Changelog](https://github.com/appercept/Delphi-WebMocks/compare/3.2.0...3.2.1)
6+
7+
**Fixed bugs:**
8+
9+
- Only the first WebMock.Assert in a test yields correct assertion result [\#58](https://github.com/appercept/Delphi-WebMocks/issues/58)
10+
- Setting content-length response header does not set response content length correctly [\#56](https://github.com/appercept/Delphi-WebMocks/issues/56)
11+
- WithQueryParam assertion is not correctly testing duplicates [\#54](https://github.com/appercept/Delphi-WebMocks/issues/54)
12+
- The History interface does not work as documented [\#53](https://github.com/appercept/Delphi-WebMocks/issues/53)
13+
14+
**Merged pull requests:**
15+
16+
- fix: Restore History interface [\#60](https://github.com/appercept/Delphi-WebMocks/pull/60) ([rhatherall](https://github.com/rhatherall))
17+
- fix: Allow multiple assertions [\#59](https://github.com/appercept/Delphi-WebMocks/pull/59) ([rhatherall](https://github.com/rhatherall))
18+
- fix: Allow setting Content-Length by header [\#57](https://github.com/appercept/Delphi-WebMocks/pull/57) ([rhatherall](https://github.com/rhatherall))
19+
- fix: Allow duplicate query parameter matching [\#55](https://github.com/appercept/Delphi-WebMocks/pull/55) ([rhatherall](https://github.com/rhatherall))
20+
321
## [3.2.0](https://github.com/appercept/Delphi-WebMocks/tree/3.2.0) (2022-06-20)
422

523
[Full Changelog](https://github.com/appercept/Delphi-WebMocks/compare/3.1.0...3.2.0)

Delphinus.Info.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
"licenses": [{ "type": "Apache 2.0", "file": "LICENSE" }],
55
"platforms": "Linux64;OSX32;OSX64;Win32;Win64",
66
"package_compiler_min": 29,
7-
"package_compiler_max": 34,
7+
"package_compiler_max": 36,
88
"compiler_min": 29,
9-
"compiler_max": 34,
9+
"compiler_max": 36,
1010
"dependencies": []
1111
}

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ should install version
2020
[2.0.0](https://github.com/appercept/Delphi-WebMocks/releases/tag/2.0.0).
2121

2222
## Installation: GetIt
23-
[WebMocks 3.1.0](https://getitnow.embarcadero.com/webmocks/) is available
23+
[WebMocks 3.2.0](https://getitnow.embarcadero.com/webmocks/) is available
2424
through Embarcadero's package manager for Delphi
2525
[GetIt](https://getitnow.embarcadero.com/). If you have a recent version of
2626
Delphi including GetIt then this should be the preferred installation method.
@@ -34,7 +34,7 @@ not be found in your test projects.
3434

3535
## Installation: Manual
3636
1. Download and extract the latest version
37-
[3.2.0](https://github.com/appercept/Delphi-WebMocks/archive/3.2.0.zip).
37+
[3.2.1](https://github.com/appercept/Delphi-WebMocks/archive/3.2.1.zip).
3838
2. In "Tools > Options" under the "Language / Delphi / Library" add the
3939
extracted `Source` directory to the "Library path" and "Browsing path".
4040

@@ -117,7 +117,7 @@ end.
117117
```
118118

119119
By default `TWebMock` will bind to a port dynamically assigned start at `8080`.
120-
This behaviour can be overriden by specifying a port at creation.
120+
This behaviour can be overridden by specifying a port at creation.
121121
```Delphi
122122
WebMock := TWebMock.Create(8088);
123123
```
@@ -351,7 +351,7 @@ WebMock.StubRequest('GET', '/')
351351

352352
#### Stubbed Response Content: Fixture Files
353353
When stubbing responses with binary or large content it is likely easier to
354-
provide the content as a file. This can be acheived using `WithBodyFile`
354+
provide the content as a file. This can be achieved using `WithBodyFile`
355355
which has the same signature as `WithBody` but the first argument is the
356356
path to a file.
357357
```Delphi
@@ -360,7 +360,7 @@ WebMock.StubRequest('GET', '/').WithBodyFile('image.jpg');
360360

361361
The Delphi-WebMocks will attempt to set the content-type according to the file
362362
extension. If the file type is unknown then the content-type will default to
363-
`application/octet-stream`. The content-type can be overriden with the second
363+
`application/octet-stream`. The content-type can be overridden with the second
364364
argument. e.g.
365365
```Delphi
366366
WebMock.StubRequest('GET', '/').WithBodyFile('file.myext', 'application/xml');
@@ -487,7 +487,7 @@ performing extra unwanted requests.
487487
This project follows [Semantic Versioning](https://semver.org).
488488

489489
## License
490-
Copyright ©2019-2022 Richard Hatherall <[email protected]>
490+
Copyright ©2019-2024 Richard Hatherall <[email protected]>
491491

492492
WebMocks is distributed under the terms of the Apache License (Version 2.0).
493493

Source/WebMock.Assertion.pas

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ interface
3030
uses
3131
DUnitX.TestFramework,
3232
System.Classes,
33+
System.Generics.Collections,
3334
System.RegularExpressions,
3435
System.Rtti,
3536
WebMock.HTTP.Messages,
@@ -40,10 +41,10 @@ interface
4041
TWebMockAssertion = class(TObject)
4142
private
4243
FMatcher: IWebMockHTTPRequestMatcher;
43-
FHistory: IInterfaceList;
44+
FHistory: TList<IWebMockHTTPRequest>;
4445
function MatchesHistory: Boolean;
4546
public
46-
constructor Create(const AHistory: IInterfaceList);
47+
constructor Create(const AHistory: TList<IWebMockHTTPRequest>);
4748
function Delete(const AURI: string): TWebMockAssertion;
4849
function Get(const AURI: string): TWebMockAssertion;
4950
function Head(const AURI: string): TWebMockAssertion;
@@ -70,7 +71,7 @@ TWebMockAssertion = class(TObject)
7071
function WithXML(const AXPath: string; APattern: TRegEx): TWebMockAssertion; overload;
7172
procedure WasRequested;
7273
procedure WasNotRequested;
73-
property History: IInterfaceList read FHistory;
74+
property History: TList<IWebMockHTTPRequest> read FHistory;
7475
property Matcher: IWebMockHTTPRequestMatcher read FMatcher;
7576
end;
7677

@@ -84,7 +85,7 @@ implementation
8485
WebMock.StringRegExMatcher,
8586
WebMock.StringWildcardMatcher;
8687

87-
constructor TWebMockAssertion.Create(const AHistory: IInterfaceList);
88+
constructor TWebMockAssertion.Create(const AHistory: TList<IWebMockHTTPRequest>);
8889
begin
8990
inherited Create;
9091
FHistory := AHistory;
@@ -156,22 +157,20 @@ function TWebMockAssertion.Request(const AMethod, AURI: string): TWebMockAsserti
156157

157158
procedure TWebMockAssertion.WasNotRequested;
158159
begin
160+
Assert.IsTrue(True);
159161
try
160162
if MatchesHistory then
161-
Assert.Fail(Format('Found request matching %s', [Matcher.ToString]))
162-
else
163-
Assert.Pass(Format('Did not find request matching %s', [Matcher.ToString]));
163+
Assert.Fail(Format('Found request matching %s', [Matcher.ToString]));
164164
finally
165165
Free;
166166
end;
167167
end;
168168

169169
procedure TWebMockAssertion.WasRequested;
170170
begin
171+
Assert.IsTrue(True);
171172
try
172-
if MatchesHistory then
173-
Assert.Pass(Format('Found request matching %s', [Matcher.ToString]))
174-
else
173+
if not MatchesHistory then
175174
Assert.Fail(Format('Expected to find request matching %s', [Matcher.ToString]));
176175
finally
177176
Free;

0 commit comments

Comments
 (0)