Skip to content

Commit 45b99d0

Browse files
committed
Improve text length in docs
1 parent 32e3794 commit 45b99d0

File tree

2 files changed

+44
-30
lines changed

2 files changed

+44
-30
lines changed

README.md

Lines changed: 43 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -6,34 +6,39 @@
66

77
<!-- MDOC !-->
88

9-
`Bypass` provides a quick way to create a custom plug that can be put in place instead of an actual
10-
HTTP server to return prebaked responses to client requests. This is most useful in tests, when you
11-
want to create a mock HTTP server and test how your HTTP client handles different types of
12-
responses from the server.
9+
`Bypass` provides a quick way to create a custom plug that can be put in place
10+
instead of an actual HTTP server to return prebaked responses to client
11+
requests. This is most useful in tests, when you want to create a mock HTTP
12+
server and test how your HTTP client handles different types of responses from
13+
the server.
1314

1415
Bypass supports Elixir 1.6 and OTP 20 and up. It works with Cowboy 1 and 2.
1516

1617
## Usage
1718

18-
To use Bypass in a test case, open a connection and use its port to connect your client to it.
19+
To use Bypass in a test case, open a connection and use its port to connect your
20+
client to it.
1921

20-
If you want to test what happens when the HTTP server goes down, use `Bypass.down/1` to close the
21-
TCP socket and `Bypass.up/1` to start listening on the same port again. Both functions block until
22-
the socket updates its state.
22+
If you want to test what happens when the HTTP server goes down, use
23+
`Bypass.down/1` to close the TCP socket and `Bypass.up/1` to start listening on
24+
the same port again. Both functions block until the socket updates its state.
2325

2426
### Expect Functions
2527

2628
You can take any of the following approaches:
27-
* `expect/2` or `expect_once/2` to install a generic function that all calls to bypass will use
29+
30+
* `expect/2` or `expect_once/2` to install a generic function that all calls to
31+
bypass will use
2832
* `expect/4` and/or `expect_once/4` to install specific routes (method and path)
2933
* `stub/4` to install specific routes without expectations
30-
* a combination of the above, where the routes will be used first, and then the generic version
31-
will be used as default
34+
* a combination of the above, where the routes will be used first, and then the
35+
generic version will be used as default
3236

3337
### Example
3438

35-
In the following example `TwitterClient.start_link()` takes the endpoint URL as its argument
36-
allowing us to make sure it will connect to the running instance of Bypass.
39+
In the following example `TwitterClient.start_link()` takes the endpoint URL as
40+
its argument allowing us to make sure it will connect to the running instance of
41+
Bypass.
3742

3843
```elixir
3944
defmodule TwitterClientTest do
@@ -81,26 +86,31 @@ defmodule TwitterClientTest do
8186
end
8287
```
8388

84-
That's all you need to do. Bypass automatically sets up an `on_exit` hook to close its socket when
85-
the test finishes running.
89+
That's all you need to do. Bypass automatically sets up an `on_exit` hook to
90+
close its socket when the test finishes running.
8691

87-
Multiple concurrent Bypass instances are supported, all will have a different unique port. Concurrent
88-
requests are also supported on the same instance.
92+
Multiple concurrent Bypass instances are supported, all will have a different
93+
unique port. Concurrent requests are also supported on the same instance.
8994

90-
> Note: `Bypass.open/0` **must not** be called in a `setup_all` blocks due to the way Bypass verifies the expectations at the end of each
91-
> test.
95+
> Note: `Bypass.open/0` **must not** be called in a `setup_all` blocks due to
96+
> the way Bypass verifies the expectations at the end of each test.
9297
9398
## How to use with ESpec
9499

95-
While Bypass primarily targets ExUnit, the official Elixir builtin test framework, it can also be used with [ESpec](https://hex.pm/packages/espec). The test configuration is basically the same, there are only two differences:
100+
While Bypass primarily targets ExUnit, the official Elixir builtin test
101+
framework, it can also be used with [ESpec](https://hex.pm/packages/espec). The
102+
test configuration is basically the same, there are only two differences:
96103

97-
1. In your Mix config file, you must declare which test framework Bypass is being used with (defaults to `:ex_unit`). This simply disables the automatic integration with some hooks provided by `ExUnit`.
104+
1. In your Mix config file, you must declare which test framework Bypass is
105+
being used with (defaults to `:ex_unit`). This simply disables the automatic
106+
integration with some hooks provided by `ExUnit`.
98107

99108
```elixir
100109
config :bypass, test_framework: :espec
101110
```
102111

103-
2. In your specs, you must explicitly verify the declared expectations. You can do it in the `finally` block.
112+
2. In your specs, you must explicitly verify the declared expectations. You can
113+
do it in the `finally` block.
104114

105115
```elixir
106116
defmodule TwitterClientSpec do
@@ -130,7 +140,8 @@ end
130140

131141
## Configuration options
132142

133-
Set `:enable_debug_log` to `true` in the application environment to make Bypass log what it's doing:
143+
Set `:enable_debug_log` to `true` in the application environment to make Bypass
144+
log what it's doing:
134145

135146
```elixir
136147
config :bypass, enable_debug_log: true
@@ -145,12 +156,13 @@ Add bypass to your list of dependencies in mix.exs:
145156
```elixir
146157
def deps do
147158
[
148-
{:bypass, "~> 1.0", only: :test}
159+
{:bypass, "~> 2.0", only: :test}
149160
]
150161
end
151162
```
152163

153-
We do not recommended adding `:bypass` to the list of applications in your `mix.exs`.
164+
We do not recommended adding `:bypass` to the list of applications in your
165+
`mix.exs`.
154166

155167
## License
156168

@@ -164,8 +176,10 @@ This software is licensed under [the MIT license](LICENSE).
164176

165177
This project is maintained and funded by [PSPDFKit](https://pspdfkit.com/).
166178

167-
Please ensure
168-
[you signed our CLA](https://pspdfkit.com/guides/web/current/miscellaneous/contributing/) so we can
169-
accept your contributions.
179+
Please ensure [you signed our
180+
CLA](https://pspdfkit.com/guides/web/current/miscellaneous/contributing/) so we
181+
can accept your contributions.
170182

171-
See [our other open source projects](https://github.com/PSPDFKit-labs), read [our blog](https://pspdfkit.com/blog/) or say hello on Twitter ([@PSPDFKit](https://twitter.com/pspdfkit)).
183+
See [our other open source projects](https://github.com/PSPDFKit-labs), read
184+
[our blog](https://pspdfkit.com/blog/) or say hello on Twitter
185+
([@PSPDFKit](https://twitter.com/pspdfkit)).

lib/bypass.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ defmodule Bypass do
2424
2525
## Options
2626
27-
- `port` - Optional TCP port to listen to requests
27+
- `port` - Optional TCP port to listen to requests.
2828
2929
## Examples
3030

0 commit comments

Comments
 (0)