Skip to content

Commit c89a28a

Browse files
Property-based testing with Stream Data for VoteCalculator
1 parent cd6490b commit c89a28a

File tree

15 files changed

+97
-34
lines changed

15 files changed

+97
-34
lines changed

.formatter.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[
2-
import_deps: [:ecto, :phoenix],
2+
import_deps: [:ecto, :phoenix, :stream_data],
33
inputs: ["*.{ex,exs}", "priv/*/seeds.exs", "{config,lib,test}/**/*.{ex,exs}"],
44
subdirectories: ["priv/*/migrations"]
55
]

config/cards.exs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ config :pointing_party,
1515
Update the application to save an individual's vote and the final card points to the database.
1616
"""
1717
},
18-
1918
%{
2019
title: "Add Guardian dependency",
2120
description: """
@@ -34,5 +33,5 @@ config :pointing_party,
3433
description: """
3534
Update our existing authentication flow to use the newly created Auth module.
3635
"""
37-
},
36+
}
3837
]

lib/pointing_party/account.ex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ defmodule PointingParty.Account do
1111

1212
def create(attrs) do
1313
changeset = changeset(%Account{}, attrs)
14+
1415
if changeset.valid? do
1516
account = apply_changes(changeset)
1617
{:ok, account}
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
defmodule PointingPartyWeb.Presence do
2-
use Phoenix.Presence, otp_app: :pointing_party,
3-
pubsub_server: PointingParty.PubSub
2+
use Phoenix.Presence,
3+
otp_app: :pointing_party,
4+
pubsub_server: PointingParty.PubSub
45
end

lib/pointing_party_web/channels/room_channel.ex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ defmodule PointingPartyWeb.RoomChannel do
3232
end
3333

3434
defp initialize_state(%{assigns: %{cards: _cards}} = socket), do: socket
35+
3536
defp initialize_state(socket) do
3637
[first | cards] = Card.cards()
3738

lib/pointing_party_web/controllers/session_controller.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ defmodule PointingPartyWeb.SessionController do
1515
|> put_session(:username, username)
1616
|> redirect(to: "/cards")
1717
|> halt()
18+
1819
{:error, changeset} ->
1920
render(conn, "new.html", changeset: changeset)
2021
end
2122
end
2223

2324
def delete(conn, _params) do
24-
clear_session(conn)
25-
|> redirect(to: "/login") |> halt()
25+
clear_session(conn) |> redirect(to: "/login") |> halt()
2626
end
2727
end

lib/pointing_party_web/plugs/auth.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ defmodule PointingPartyWeb.Plugs.Auth do
1212
end
1313

1414
defp authenticate(conn) do
15-
get_session(conn, :username)
15+
get_session(conn, :username)
1616
end
1717
end

mix.exs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ defmodule PointingParty.MixProject do
4141
{:gettext, "~> 0.11"},
4242
{:jason, "~> 1.0"},
4343
{:plug_cowboy, "~> 2.0"},
44-
{:ex_machina, "~> 2.3", only: :test}
44+
{:ex_machina, "~> 2.3", only: :test},
45+
{:stream_data, "~> 0.1", only: :test}
4546
]
4647
end
4748
end

mix.lock

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,6 @@
2121
"plug_crypto": {:hex, :plug_crypto, "1.0.0", "18e49317d3fa343f24620ed22795ec29d4a5e602d52d1513ccea0b07d8ea7d4d", [:mix], [], "hexpm"},
2222
"postgrex": {:hex, :postgrex, "0.14.3", "5754dee2fdf6e9e508cbf49ab138df964278700b764177e8f3871e658b345a1e", [:mix], [{:connection, "~> 1.0", [hex: :connection, repo: "hexpm", optional: false]}, {:db_connection, "~> 2.0", [hex: :db_connection, repo: "hexpm", optional: false]}, {:decimal, "~> 1.5", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}], "hexpm"},
2323
"ranch": {:hex, :ranch, "1.7.1", "6b1fab51b49196860b733a49c07604465a47bdb78aa10c1c16a3d199f7f8c881", [:rebar3], [], "hexpm"},
24+
"stream_data": {:hex, :stream_data, "0.4.3", "62aafd870caff0849a5057a7ec270fad0eb86889f4d433b937d996de99e3db25", [:mix], [], "hexpm"},
2425
"telemetry": {:hex, :telemetry, "0.4.0", "8339bee3fa8b91cb84d14c2935f8ecf399ccd87301ad6da6b71c09553834b2ab", [:rebar3], [], "hexpm"},
2526
}

priv/repo/migrations/20190708014847_create_cards.exs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@ defmodule PointingParty.Repo.Migrations.CreateCards do
33

44
def change do
55
create table(:cards) do
6-
add :title, :string
7-
add :description, :string
6+
add(:title, :string)
7+
add(:description, :string)
88

99
timestamps()
1010
end
11-
1211
end
1312
end

0 commit comments

Comments
 (0)