You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* a combination of the above, where the routes will be used first, and then the
35
+
generic version will be used as default
113
36
114
37
### Example
115
38
116
-
In the following example `TwitterClient.start_link()` takes the endpoint URL as its argument
117
-
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.
118
42
119
43
```elixir
120
44
defmoduleTwitterClientTestdo
@@ -162,33 +86,31 @@ defmodule TwitterClientTest do
162
86
end
163
87
```
164
88
165
-
That's all you need to do. Bypass automatically sets up an `on_exit` hook to close its socket when
166
-
the test finishes running.
167
-
168
-
Multiple concurrent Bypass instances are supported, all will have a different unique port. Concurrent
169
-
requests are also supported on the same instance.
170
-
171
-
In case you need to assign a specific port to a Bypass instance to listen on, you can pass the
172
-
`port` option to `Bypass.open()`:
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.
173
91
174
-
```elixir
175
-
bypass =Bypass.open(port:1234)
176
-
```
92
+
Multiple concurrent Bypass instances are supported, all will have a different
93
+
unique port. Concurrent requests are also supported on the same instance.
177
94
178
-
> 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
179
-
> 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.
180
97
181
98
## How to use with ESpec
182
99
183
-
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:
184
103
185
-
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`.
186
107
187
108
```elixir
188
109
config :bypass, test_framework::espec
189
110
```
190
111
191
-
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.
192
114
193
115
```elixir
194
116
defmoduleTwitterClientSpecdo
@@ -218,12 +140,30 @@ end
218
140
219
141
## Configuration options
220
142
221
-
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:
222
145
223
146
```elixir
224
147
config :bypass, enable_debug_log:true
225
148
```
226
149
150
+
<!-- MDOC !-->
151
+
152
+
## Installation
153
+
154
+
Add bypass to your list of dependencies in mix.exs:
155
+
156
+
```elixir
157
+
defdepsdo
158
+
[
159
+
{:bypass, "~> 2.0", only::test}
160
+
]
161
+
end
162
+
```
163
+
164
+
We do not recommended adding `:bypass` to the list of applications in your
165
+
`mix.exs`.
166
+
227
167
## License
228
168
229
169
This software is licensed under [the MIT license](LICENSE).
@@ -236,8 +176,10 @@ This software is licensed under [the MIT license](LICENSE).
236
176
237
177
This project is maintained and funded by [PSPDFKit](https://pspdfkit.com/).
238
178
239
-
Please ensure
240
-
[you signed our CLA](https://pspdfkit.com/guides/web/current/miscellaneous/contributing/) so we can
241
-
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.
242
182
243
-
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
0 commit comments