Skip to content

Commit

Permalink
Merge pull request #113 from kianmeng/misc-doc-changes
Browse files Browse the repository at this point in the history
Misc doc changes
  • Loading branch information
ream88 authored Nov 4, 2020
2 parents 8116eb3 + 0fda358 commit a2f8a74
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 32 deletions.
3 changes: 1 addition & 2 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2015–2016 PSPDFKit GmbH (pspdfkit.com)
Copyright (c) 2015–2020 PSPDFKit GmbH (pspdfkit.com)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand All @@ -19,4 +19,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

58 changes: 31 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
# Bypass

<!-- MDOC !-->

[![Build Status](https://travis-ci.org/PSPDFKit-labs/bypass.svg?branch=master)](https://travis-ci.org/PSPDFKit-labs/bypass)
[![Module Version](https://img.shields.io/hexpm/v/bypass.svg)](https://hex.pm/packages/bypass)
[![Hex Docs](https://img.shields.io/badge/hex-docs-lightgreen.svg)](https://hexdocs.pm/bypass/)
[![Total Download](https://img.shields.io/hexpm/dt/bypass.svg)](https://hex.pm/packages/bypass)
[![License](https://img.shields.io/hexpm/l/bypass.svg)](https://github.com/PSPDFKit-labs/bypass/blob/master/LICENSE)
[![Last Updated](https://img.shields.io/github/last-commit/PSPDFKit-labs/bypass.svg)](https://github.com/PSPDFKit-labs/bypass/commits/master)

[Online Documentation](https://hexdocs.pm/bypass).

<!-- MDOC !-->

`Bypass` provides a quick way to create a custom plug that can be put in place
instead of an actual HTTP server to return prebaked responses to client
Expand Down Expand Up @@ -105,38 +109,38 @@ test configuration is basically the same, there are only two differences:
being used with (defaults to `:ex_unit`). This simply disables the automatic
integration with some hooks provided by `ExUnit`.

```elixir
config :bypass, test_framework: :espec
```
```elixir
config :bypass, test_framework: :espec
```

2. In your specs, you must explicitly verify the declared expectations. You can
do it in the `finally` block.

```elixir
defmodule TwitterClientSpec do
use ESpec, async: true
```elixir
defmodule TwitterClientSpec do
use ESpec, async: true

before do
bypass = Bypass.open()
{:shared, bypass: bypass}
end
before do
bypass = Bypass.open()
{:shared, bypass: bypass}
end

finally do
Bypass.verify_expectations!(shared.bypass)
end
finally do
Bypass.verify_expectations!(shared.bypass)
end

specify "the client can handle an error response" do
Bypass.expect_once(shared.bypass, "POST", "/1.1/statuses/update.json", fn conn ->
Plug.Conn.resp(conn, 429, ~s<{"errors": [{"code": 88, "message": "Rate limit exceeded"}]}>)
end)
specify "the client can handle an error response" do
Bypass.expect_once(shared.bypass, "POST", "/1.1/statuses/update.json", fn conn ->
Plug.Conn.resp(conn, 429, ~s<{"errors": [{"code": 88, "message": "Rate limit exceeded"}]}>)
end)

{:ok, client} = TwitterClient.start_link(url: endpoint_url(shared.bypass.port))
assert {:error, :rate_limited} == TwitterClient.post_tweet(client, "Elixir is awesome!")
end
{:ok, client} = TwitterClient.start_link(url: endpoint_url(shared.bypass.port))
assert {:error, :rate_limited} == TwitterClient.post_tweet(client, "Elixir is awesome!")
end

defp endpoint_url(port), do: "http://localhost:#{port}/"
end
```
defp endpoint_url(port), do: "http://localhost:#{port}/"
end
```

## Configuration options

Expand All @@ -151,7 +155,7 @@ config :bypass, enable_debug_log: true

## Installation

Add bypass to your list of dependencies in mix.exs:
Add `:bypass` to your list of dependencies in mix.exs:

```elixir
def deps do
Expand Down
2 changes: 1 addition & 1 deletion lib/bypass.ex
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ defmodule Bypass do
do: Bypass.Instance.call(pid, {:stub, method, path, fun})

@doc """
Makes a expection to pass.
Makes an expectation to pass.
```
Bypass.expect(bypass, fn _conn ->
Expand Down
7 changes: 5 additions & 2 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,10 @@ defmodule Bypass.Mixfile do
defp docs do
[
main: "Bypass",
api_reference: false,
source_url: @source_url,
source_ref: "v#{@version}"
source_ref: "v#{@version}",
extras: ["CHANGELOG.md"]
]
end

Expand All @@ -58,10 +60,11 @@ defmodule Bypass.Mixfile do

defp package do
[
files: ["lib", "mix.exs", "README.md", "LICENSE"],
files: ["lib", "mix.exs", "README.md", "CHANGELOG.md", "LICENSE"],
maintainers: ["PSPDFKit"],
licenses: ["MIT"],
links: %{
"Changelog" => "#{@source_url}/blob/master/CHANGELOG.md",
"GitHub" => @source_url,
"PSPDFKit" => "https://pspdfkit.com"
}
Expand Down

0 comments on commit a2f8a74

Please sign in to comment.