11# Bypass
22
3+ <!-- MDOC !-->
4+
35[ ![ Build Status] ( https://travis-ci.org/PSPDFKit-labs/bypass.svg?branch=master )] ( https://travis-ci.org/PSPDFKit-labs/bypass )
6+ [ ![ Module Version] ( https://img.shields.io/hexpm/v/bypass.svg )] ( https://hex.pm/packages/bypass )
7+ [ ![ Hex Docs] ( https://img.shields.io/badge/hex-docs-lightgreen.svg )] ( https://hexdocs.pm/bypass/ )
8+ [ ![ Total Download] ( https://img.shields.io/hexpm/dt/bypass.svg )] ( https://hex.pm/packages/bypass )
9+ [ ![ License] ( https://img.shields.io/hexpm/l/bypass.svg )] ( https://github.com/PSPDFKit-labs/bypass/blob/master/LICENSE )
10+ [ ![ Last Updated] ( https://img.shields.io/github/last-commit/PSPDFKit-labs/bypass.svg )] ( https://github.com/PSPDFKit-labs/bypass/commits/master )
411
5- [ Online Documentation] ( https://hexdocs.pm/bypass ) .
6-
7- <!-- MDOC !-->
812
913` Bypass ` provides a quick way to create a custom plug that can be put in place
1014instead of an actual HTTP server to return prebaked responses to client
@@ -105,38 +109,38 @@ test configuration is basically the same, there are only two differences:
105109 being used with (defaults to ` :ex_unit ` ). This simply disables the automatic
106110 integration with some hooks provided by ` ExUnit ` .
107111
108- ``` elixir
109- config :bypass , test_framework: :espec
110- ```
112+ ``` elixir
113+ config :bypass , test_framework: :espec
114+ ```
111115
1121162 . In your specs, you must explicitly verify the declared expectations. You can
113117 do it in the ` finally ` block.
114118
115- ``` elixir
116- defmodule TwitterClientSpec do
117- use ESpec , async: true
119+ ``` elixir
120+ defmodule TwitterClientSpec do
121+ use ESpec , async: true
118122
119- before do
120- bypass = Bypass .open ()
121- {:shared , bypass: bypass}
122- end
123+ before do
124+ bypass = Bypass .open ()
125+ {:shared , bypass: bypass}
126+ end
123127
124- finally do
125- Bypass .verify_expectations! (shared.bypass)
126- end
128+ finally do
129+ Bypass .verify_expectations! (shared.bypass)
130+ end
127131
128- specify " the client can handle an error response" do
129- Bypass .expect_once (shared.bypass, " POST" , " /1.1/statuses/update.json" , fn conn ->
130- Plug .Conn .resp (conn, 429 , ~s< {"errors": [{"code": 88, "message": "Rate limit exceeded"}]}> )
131- end )
132+ specify " the client can handle an error response" do
133+ Bypass .expect_once (shared.bypass, " POST" , " /1.1/statuses/update.json" , fn conn ->
134+ Plug .Conn .resp (conn, 429 , ~s< {"errors": [{"code": 88, "message": "Rate limit exceeded"}]}> )
135+ end )
132136
133- {:ok , client} = TwitterClient .start_link (url: endpoint_url (shared.bypass.port))
134- assert {:error , :rate_limited } == TwitterClient .post_tweet (client, " Elixir is awesome!" )
135- end
137+ {:ok , client} = TwitterClient .start_link (url: endpoint_url (shared.bypass.port))
138+ assert {:error , :rate_limited } == TwitterClient .post_tweet (client, " Elixir is awesome!" )
139+ end
136140
137- defp endpoint_url (port), do: " http://localhost:#{ port } /"
138- end
139- ```
141+ defp endpoint_url (port), do: " http://localhost:#{ port } /"
142+ end
143+ ```
140144
141145## Configuration options
142146
@@ -151,7 +155,7 @@ config :bypass, enable_debug_log: true
151155
152156## Installation
153157
154- Add bypass to your list of dependencies in mix.exs:
158+ Add ` : bypass` to your list of dependencies in mix.exs:
155159
156160``` elixir
157161def deps do
0 commit comments