@@ -78,4 +78,41 @@ defmodule Igniter.TestTest do
7878 end
7979 end
8080 end
81+
82+ describe "assert_moves/3" do
83+ test "passes when file is moved" do
84+ test_project ( files: % { "old.exs" => "content" } )
85+ |> Igniter . move_file ( "old.exs" , "new.exs" )
86+ |> assert_moves ( "old.exs" , "new.exs" )
87+ end
88+
89+ test "fails when file is not moved" do
90+ assert_raise ExUnit.AssertionError ,
91+ ~r/ Expected \" old.exs\" to have been moved, but it was not.\n \n No files were moved./ ,
92+ fn ->
93+ test_project ( files: % { "old.exs" => "content" } )
94+ |> assert_moves ( "old.exs" , "new.exs" )
95+ end
96+ end
97+
98+ test "fails when different file is moved" do
99+ assert_raise ExUnit.AssertionError ,
100+ ~r/ Expected \" one.exs\" to have been moved, but it was not.\n \n The following files were moved:\n \n \* two.exs\n ↳ three.exs/ ,
101+ fn ->
102+ test_project ( files: % { "one.exs" => "content" , "two.exs" => "content" } )
103+ |> Igniter . move_file ( "two.exs" , "three.exs" )
104+ |> assert_moves ( "one.exs" , "three.exs" )
105+ end
106+ end
107+
108+ test "fails when file is not moved to a different location" do
109+ assert_raise ExUnit.AssertionError ,
110+ ~r/ Expected \" old.exs\" to have been moved to:\n \n new.exs\n \n But it was moved to:\n \n mature.exs/ ,
111+ fn ->
112+ test_project ( files: % { "old.exs" => "content" } )
113+ |> Igniter . move_file ( "old.exs" , "mature.exs" )
114+ |> assert_moves ( "old.exs" , "new.exs" )
115+ end
116+ end
117+ end
81118end
0 commit comments