Last active
May 17, 2020 16:46
-
-
Save karlosmid/9a046c059851b99686403621c44a2467 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Testivator.CRM.DatafileSpec do | |
@moduledoc """ | |
This module holds espec spec demonstrations for CRM.Datafile module. | |
""" | |
use ESpec.Phoenix, async: false, model: DataFile | |
alias Testivator.CRM.DataFile | |
alias Testivator.File | |
import Mock | |
context "Changeset" do | |
it "connection timeout" do | |
file = %Plug.Upload{ | |
content_type: "application/pdf", | |
filename: "document.pdf", | |
path: Plug.Upload.random_file!(".pdf")} | |
changeset = DataFile.changeset(%DataFile{}, %{inserted_at: "none", file: file}) | |
expect(to(changeset.valid?, be_truthy())) | |
expect(to(changeset.changes.file.file_name, eq(file))) | |
end | |
it "valid attributes" do | |
file = %Plug.Upload{ | |
content_type: "application/pdf", | |
filename: "document.pdf", | |
path: Plug.Upload.random_file!(".pdf")} | |
with_mock(File, [ | |
store: fn | |
({file, _}) -> {:ok, file} | |
end | |
]) do | |
changeset = DataFile.changeset(%DataFile{}, %{inserted_at: "none", file: file}) | |
expect(to(changeset.valid?, be_truthy())) | |
expect(to(changeset.changes.file.file_name, eq(file))) | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment