Page MenuHomePhorge

No OneTemporary

Size
4 KB
Referenced Files
None
Subscribers
None
diff --git a/examples/phoenix_app/mix.exs b/examples/phoenix_app/mix.exs
index 4abf84c..8466b90 100644
--- a/examples/phoenix_app/mix.exs
+++ b/examples/phoenix_app/mix.exs
@@ -1,49 +1,49 @@
defmodule PhoenixApp.Mixfile do
use Mix.Project
def project do
[
app: :phoenix_app,
version: "0.0.1",
elixir: "~> 1.5",
elixirc_paths: elixirc_paths(Mix.env()),
compilers: [:phoenix] ++ Mix.compilers(),
start_permanent: Mix.env() == :prod,
aliases: aliases(),
deps: deps()
]
end
# Configuration for the OTP application.
#
# Type `mix help compile.app` for more information.
def application do
[
mod: {PhoenixApp.Application, []},
extra_applications: [:logger, :runtime_tools]
]
end
# Specifies which paths to compile per environment.
defp elixirc_paths(:test), do: ["lib", "test/support"]
defp elixirc_paths(_), do: ["lib"]
defp aliases() do
[test: ["ecto.create --quiet", "ecto.migrate", "test"]]
end
# Specifies your project dependencies.
#
# Type `mix help deps` for examples and options.
defp deps do
[
{:open_api_spex, path: "../../"},
{:ecto, "~> 2.2"},
{:sqlite_ecto2, "~> 2.4"},
{:phoenix, "~> 1.4"},
{:plug_cowboy, "~> 2.0"},
{:jason, "~> 1.0"},
- {:dialyxir, "1.0.0-rc.6"}
+ {:dialyxir, "1.0.0-rc.6", only: [:dev], runtime: false}
]
end
end
diff --git a/examples/phoenix_app/priv/repo/.gitignore b/examples/phoenix_app/priv/repo/.gitignore
new file mode 100644
index 0000000..1550c57
--- /dev/null
+++ b/examples/phoenix_app/priv/repo/.gitignore
@@ -0,0 +1 @@
+phoenix_app_test.*
diff --git a/examples/phoenix_app/test/phoenix_app_web/controllers/user_controller_test.exs b/examples/phoenix_app/test/phoenix_app_web/controllers/user_controller_test.exs
index ee3b8ad..d5a085e 100644
--- a/examples/phoenix_app/test/phoenix_app_web/controllers/user_controller_test.exs
+++ b/examples/phoenix_app/test/phoenix_app_web/controllers/user_controller_test.exs
@@ -1,57 +1,65 @@
defmodule PhoenixAppWeb.UserControllerTest do
use PhoenixAppWeb.ConnCase, async: true
- import OpenApiSpex.Test.Assertions
+ import OpenApiSpex.TestAssertions
setup do
%{spec: PhoenixAppWeb.ApiSpec.spec()}
end
test "create user", %{conn: conn, spec: spec} do
conn
|> Plug.Conn.put_req_header("content-type", "application/json")
- |> post(user_path(conn, :create, 1), %{"user" => %{"name" => "Joe", "email" => "joe@gmail.com"}})
+ |> post(user_path(conn, :create, 1), %{
+ "user" => %{"name" => "Joe", "email" => "joe@gmail.com"}
+ })
|> json_response(201)
|> assert_schema("UserResponse", spec)
end
test "get user", %{conn: conn, spec: spec} do
- %{id: id} = PhoenixApp.Repo.insert!(%PhoenixApp.Accounts.User{name: "Carl", email: "Carl@yahoo.com"})
+ %{id: id} =
+ PhoenixApp.Repo.insert!(%PhoenixApp.Accounts.User{name: "Carl", email: "Carl@yahoo.com"})
conn
|> Plug.Conn.put_req_header("accept", "application/json")
|> get(user_path(conn, :show, id))
|> json_response(200)
|> assert_schema("UserResponse", spec)
end
test "list users", %{conn: conn, spec: spec} do
- %{id: id1} = PhoenixApp.Repo.insert!(%PhoenixApp.Accounts.User{name: "Aaron", email: "aaron@hotmail.com"})
- %{id: id2} = PhoenixApp.Repo.insert!(%PhoenixApp.Accounts.User{name: "Benjamin", email: "ben@lycos.com"})
- %{id: id3} = PhoenixApp.Repo.insert!(%PhoenixApp.Accounts.User{name: "Chuck", email: "chuck@aol.com"})
+ %{id: id1} =
+ PhoenixApp.Repo.insert!(%PhoenixApp.Accounts.User{name: "Aaron", email: "aaron@hotmail.com"})
+
+ %{id: id2} =
+ PhoenixApp.Repo.insert!(%PhoenixApp.Accounts.User{name: "Benjamin", email: "ben@lycos.com"})
+
+ %{id: id3} =
+ PhoenixApp.Repo.insert!(%PhoenixApp.Accounts.User{name: "Chuck", email: "chuck@aol.com"})
response =
conn
|> Plug.Conn.put_req_header("accept", "application/json")
|> get(user_path(conn, :index))
|> json_response(200)
|> assert_schema("UsersResponse", spec)
assert [%{id: ^id1}, %{id: ^id2}, %{id: ^id3}] = response.data
end
test "User schema example", %{spec: spec} do
assert_schema(PhoenixAppWeb.Schemas.User.schema().example, "User", spec)
end
test "UserRequest schema example", %{spec: spec} do
assert_schema(PhoenixAppWeb.Schemas.UserRequest.schema().example, "UserRequest", spec)
end
test "UserResponse schema example", %{spec: spec} do
assert_schema(PhoenixAppWeb.Schemas.UserResponse.schema().example, "UserResponse", spec)
end
test "UsersResponse schema example", %{spec: spec} do
assert_schema(PhoenixAppWeb.Schemas.UsersResponse.schema().example, "UsersResponse", spec)
end
end

File Metadata

Mime Type
text/x-diff
Expires
Wed, Nov 27, 8:30 PM (1 d, 17 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
40739
Default Alt Text
(4 KB)

Event Timeline