Skip to content

Commit

Permalink
Fix deprecated syntax to remove compilation warnings. Add link to Rec…
Browse files Browse the repository at this point in the history
…ord documentation.
  • Loading branch information
fdbeirao committed Sep 30, 2018
1 parent 9e83127 commit 9aff3e5
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions 06-record.exs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ defmodule RecordTest do

defmodule ScopeTest do
use ExUnit.Case


# https://hexdocs.pm/elixir/Record.html
require Record
Record.defrecordp :person, first_name: nil, last_name: nil, age: nil

Expand All @@ -35,21 +36,21 @@ defmodule RecordTest do
end

test "defstruct" do
assert sample == %{__struct__: User, email: "kai@example.com", password: "trains"}
assert sample() == %{__struct__: User, email: "kai@example.com", password: "trains"}
end

test "property" do
assert sample.email == "kai@example.com"
assert sample().email == "kai@example.com"
end

test "update" do
u = sample
u = sample()
u2 = %User{u | email: "tim@example.com"}
assert u2 == %User{email: "tim@example.com", password: "trains"}
end

test "protocol" do
assert to_string(sample) == "kai@example.com"
assert to_string(sample()) == "kai@example.com"
end
end

0 comments on commit 9aff3e5

Please sign in to comment.