Skip to content

Commit

Permalink
Merge branch 'release/3.2.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
rhatherall committed Apr 18, 2024
2 parents 827d8dc + a284057 commit 5e805e5
Show file tree
Hide file tree
Showing 17 changed files with 858 additions and 363 deletions.
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
# Changelog

## [3.2.1](https://github.com/appercept/Delphi-WebMocks/tree/3.2.1) (2024-04-18)

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

**Fixed bugs:**

- Only the first WebMock.Assert in a test yields correct assertion result [\#58](https://github.com/appercept/Delphi-WebMocks/issues/58)
- Setting content-length response header does not set response content length correctly [\#56](https://github.com/appercept/Delphi-WebMocks/issues/56)
- WithQueryParam assertion is not correctly testing duplicates [\#54](https://github.com/appercept/Delphi-WebMocks/issues/54)
- The History interface does not work as documented [\#53](https://github.com/appercept/Delphi-WebMocks/issues/53)

**Merged pull requests:**

- fix: Restore History interface [\#60](https://github.com/appercept/Delphi-WebMocks/pull/60) ([rhatherall](https://github.com/rhatherall))
- fix: Allow multiple assertions [\#59](https://github.com/appercept/Delphi-WebMocks/pull/59) ([rhatherall](https://github.com/rhatherall))
- fix: Allow setting Content-Length by header [\#57](https://github.com/appercept/Delphi-WebMocks/pull/57) ([rhatherall](https://github.com/rhatherall))
- fix: Allow duplicate query parameter matching [\#55](https://github.com/appercept/Delphi-WebMocks/pull/55) ([rhatherall](https://github.com/rhatherall))

## [3.2.0](https://github.com/appercept/Delphi-WebMocks/tree/3.2.0) (2022-06-20)

[Full Changelog](https://github.com/appercept/Delphi-WebMocks/compare/3.1.0...3.2.0)
Expand Down
4 changes: 2 additions & 2 deletions Delphinus.Info.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"licenses": [{ "type": "Apache 2.0", "file": "LICENSE" }],
"platforms": "Linux64;OSX32;OSX64;Win32;Win64",
"package_compiler_min": 29,
"package_compiler_max": 34,
"package_compiler_max": 36,
"compiler_min": 29,
"compiler_max": 34,
"compiler_max": 36,
"dependencies": []
}
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ should install version
[2.0.0](https://github.com/appercept/Delphi-WebMocks/releases/tag/2.0.0).

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

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

Expand Down Expand Up @@ -117,7 +117,7 @@ end.
```

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

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

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

## License
Copyright ©2019-2022 Richard Hatherall <richard@appercept.com>
Copyright ©2019-2024 Richard Hatherall <richard@appercept.com>

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

Expand Down
19 changes: 9 additions & 10 deletions Source/WebMock.Assertion.pas
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ interface
uses
DUnitX.TestFramework,
System.Classes,
System.Generics.Collections,
System.RegularExpressions,
System.Rtti,
WebMock.HTTP.Messages,
Expand All @@ -40,10 +41,10 @@ interface
TWebMockAssertion = class(TObject)
private
FMatcher: IWebMockHTTPRequestMatcher;
FHistory: IInterfaceList;
FHistory: TList<IWebMockHTTPRequest>;
function MatchesHistory: Boolean;
public
constructor Create(const AHistory: IInterfaceList);
constructor Create(const AHistory: TList<IWebMockHTTPRequest>);
function Delete(const AURI: string): TWebMockAssertion;
function Get(const AURI: string): TWebMockAssertion;
function Head(const AURI: string): TWebMockAssertion;
Expand All @@ -70,7 +71,7 @@ TWebMockAssertion = class(TObject)
function WithXML(const AXPath: string; APattern: TRegEx): TWebMockAssertion; overload;
procedure WasRequested;
procedure WasNotRequested;
property History: IInterfaceList read FHistory;
property History: TList<IWebMockHTTPRequest> read FHistory;
property Matcher: IWebMockHTTPRequestMatcher read FMatcher;
end;

Expand All @@ -84,7 +85,7 @@ implementation
WebMock.StringRegExMatcher,
WebMock.StringWildcardMatcher;

constructor TWebMockAssertion.Create(const AHistory: IInterfaceList);
constructor TWebMockAssertion.Create(const AHistory: TList<IWebMockHTTPRequest>);
begin
inherited Create;
FHistory := AHistory;
Expand Down Expand Up @@ -156,22 +157,20 @@ function TWebMockAssertion.Request(const AMethod, AURI: string): TWebMockAsserti

procedure TWebMockAssertion.WasNotRequested;
begin
Assert.IsTrue(True);
try
if MatchesHistory then
Assert.Fail(Format('Found request matching %s', [Matcher.ToString]))
else
Assert.Pass(Format('Did not find request matching %s', [Matcher.ToString]));
Assert.Fail(Format('Found request matching %s', [Matcher.ToString]));
finally
Free;
end;
end;

procedure TWebMockAssertion.WasRequested;
begin
Assert.IsTrue(True);
try
if MatchesHistory then
Assert.Pass(Format('Found request matching %s', [Matcher.ToString]))
else
if not MatchesHistory then
Assert.Fail(Format('Expected to find request matching %s', [Matcher.ToString]));
finally
Free;
Expand Down
Loading

0 comments on commit 5e805e5

Please # to comment.