Current section
Files
Jump to
Current section
Files
lib/floppy.ex
defmodule Floppy do
@moduledoc """
Documentation for `Floppy`.
"""
defmacro assert(result, _options \\ []) do
quote do
env = __ENV__
dir = String.replace(env.file, ".exs", "")
{file, _} = env.function
path = dir <> "/" <> to_string(file) <> ".floppy"
result = inspect(unquote(result), pretty: true, limit: :infinity)
if !File.exists?(path) || System.get_env("FLOPPY_MODE") == "rewrite" do
File.mkdir_p!(dir)
File.write!(dir <> "/" <> to_string(file) <> ".floppy", result)
assert true
else
previous_result = File.read!(path)
assert previous_result == result
end
end
end
end