From aa940c36f3c2d678014a43a0b2ff7daf04e60a28 Mon Sep 17 00:00:00 2001 From: Christian Koch Date: Thu, 16 Sep 2021 22:12:06 -0500 Subject: [PATCH] WIP add top-level refactor fn and test --- lib/ex_factor/extractor.ex | 1 + test/ex_factor_test.exs | 12 +++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/ex_factor/extractor.ex b/lib/ex_factor/extractor.ex index a659523..8791422 100644 --- a/lib/ex_factor/extractor.ex +++ b/lib/ex_factor/extractor.ex @@ -56,6 +56,7 @@ defmodule ExFactor.Extractor do source_function = Keyword.get(opts, :source_function) arity = Keyword.get(opts, :arity) source_path = Keyword.get(opts, :source_path, path(source_module)) + |> IO.inspect(label: "REMOVE source_path") Remover.remove(source_path, source_function, arity) end diff --git a/test/ex_factor_test.exs b/test/ex_factor_test.exs index 44908ee..c4ebb08 100644 --- a/test/ex_factor_test.exs +++ b/test/ex_factor_test.exs @@ -2,7 +2,7 @@ defmodule ExFactorTest do use ExUnit.Case describe "refactor/1" do - test "it should refactors the functions into a new module, specified in opts" do + test "it refactors the functions into a new module, specified in opts" do File.rm("lib/ex_factor/source_module.ex") File.rm("lib/ex_factor/target_module.ex") @@ -49,9 +49,15 @@ defmodule ExFactorTest do assert file =~ "def(refactor1(arg1)) do" assert file =~ "def(refactor1([])) do" assert file =~ " @doc \"some docs\"" + assert file =~ "def pub_exists(arg_exists) do" - File.rm("lib/ex_factor/source_module.ex") - File.rm("lib/ex_factor/target_module.ex") + file = File.read!("lib/ex_factor/source_module.ex") + |> IO.inspect(label: "") + refute file =~ "def refactor1(arg1) do" + refute file =~ "def refactor1([]) do" + + # File.rm("lib/ex_factor/source_module.ex") + # File.rm("lib/ex_factor/target_module.ex") end end end