Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Sources/Fakes/Fakes.docc/Guides/DependencyInjection.md
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ final class GreetingForTimeOfDayTests: XCTestCase {
}
```

> Note: Annoyed at the setup and act repitition? Check out
> Note: Annoyed at the setup and act repetition? Check out
[Quick](https://github.com/Quick/Quick/)! It provides a simple DSL enabling
powerful test simplifications.

Expand Down
2 changes: 1 addition & 1 deletion Sources/Fakes/Fakes.docc/Guides/VerifyingCallbacks.md
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ that, because it now has logic in it, we have to [write tests for that logic](ht
Otherwise, we have no idea if a test failure is caused by something
in the production code, or something in `FakeDispatchQueue`.

Some tests that verify thet entire API for `FakeDispatchQueue` look like this:
Some tests that verify the entire API for `FakeDispatchQueue` look like this:

```swift
final class FakeDispatchQueueTests: XCTestCase {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@
This is a protocol for a `URLSession`-like object that can make
various network requests.

@Code(name: "NetworkInterface", file: "NetworkInterface-01.swift")
@Code(name: "NetworkInterface.swift", file: "NetworkInterface-01.swift")
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be better to add a file extension to enable syntax highlighting.

}

@Step {
Given this `NetworkInterface`, you might write `RecipeService`
like so:

@Code(name: "RecipeService", file: "RecipeService-01.swift")
@Code(name: "RecipeService.swift", file: "RecipeService-01.swift")
}

@Step {
Expand All @@ -41,7 +41,7 @@
<doc:DependencyInjection>) to your Subject. You decide to come up with this
first attempt at `FakeNetworkInterface`.

@Code(name: "FakeNetworkInterface", file: "FakeNetworkInterface-01.swift")
@Code(name: "FakeNetworkInterface.swift", file: "FakeNetworkInterface-01.swift")
}

@Step {
Expand All @@ -50,14 +50,14 @@
used. This is where ``Spy`` comes in. Let's rewrite `FakeNetworkInterface` using
``Spy``.

@Code(name: "FakeNetworkInterface", file: "FakeNetworkInterface-02.swift")
@Code(name: "FakeNetworkInterface.swift", file: "FakeNetworkInterface-02.swift")
}

@Step {
This is the start of everything we need to write tests for
`RecipeService`, so let's do just that.

@Code(name: "RecipeServiceTests", file: "RecipeServiceTests-01.swift")
@Code(name: "RecipeServiceTests.swift", file: "RecipeServiceTests-01.swift")
}
}
}
Expand All @@ -74,15 +74,15 @@
@Step {
First, let's start with updating `NetworkInterface`.

@Code(name: "NetworkInterface", file: "NetworkInterface-02.swift")
@Code(name: "NetworkInterface.swift", file: "NetworkInterface-02.swift")
}

@Step {
With the updated `NetworkInterface`, we also have to update
`RecipeService` to handle these new errors. For our purposes,
let's just rethrow the errors and not do anything.

@Code(name: "RecipeService", file: "RecipeService-02.swift")
@Code(name: "RecipeService.swift", file: "RecipeService-02.swift")
}

@Step {
Expand All @@ -94,7 +94,7 @@
`ThrowingSpy` is less boilerplate, and therefore easier to
understand, so we'll go with that.

@Code(name: "FakeNetworkInterface", file: "FakeNetworkInterface-03.swift")
@Code(name: "FakeNetworkInterface.swift", file: "FakeNetworkInterface-03.swift")
}

@Step {
Expand All @@ -104,7 +104,7 @@
that we're not crashing on errors. A downstream object might
take the error and present an alert with a retry option.

@Code(name: "RecipeServiceTests", file: "RecipeServiceTests-02.swift")
@Code(name: "RecipeServiceTests.swift", file: "RecipeServiceTests-02.swift")
}
}
}
Expand All @@ -125,15 +125,15 @@
As with before, let's start with `NetworkInterface`, making use
of Swift Concurrency for this.

@Code(name: "NetworkInterface", file: "NetworkInterface-03.swift")
@Code(name: "NetworkInterface.swift", file: "NetworkInterface-03.swift")
}

@Step {
With the again-updated `NetworkInterface`, we once again have
to update `RecipeService` to work with the asynchronous
`NetworkInterface`.

@Code(name: "RecipeService", file: "RecipeService-03.swift")
@Code(name: "RecipeService.swift", file: "RecipeService-03.swift")
}

@Step {
Expand All @@ -146,14 +146,14 @@
let's use the one that flattens the generics as much as
possible: `ThrowingPendableSpy`.

@Code(name: "FakeNetworkInterface", file: "FakeNetworkInterface-04.swift")
@Code(name: "FakeNetworkInterface.swift", file: "FakeNetworkInterface-04.swift")
}

@Step {
Finally, we need to update the tests to work with all these
async calls.

@Code(name: "RecipeServiceTests", file: "RecipeServiceTests-03.swift")
@Code(name: "RecipeServiceTests.swift", file: "RecipeServiceTests-03.swift")
}
}
}
Expand Down