Skip to content

Commit

Permalink
WIP add top-level refactor fn and test
Browse files Browse the repository at this point in the history
  • Loading branch information
ckochx committed Sep 17, 2021
1 parent a0a352b commit aa940c3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions lib/ex_factor/extractor.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 9 additions & 3 deletions test/ex_factor_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down Expand Up @@ -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

0 comments on commit aa940c3

Please sign in to comment.