Repository: phoenixframework/phoenix
Pull request #2153 (2017-03-04 15:14:19)

Move generated tests to test/my_app
As discussed on https://github.com/phoenixframework/phoenix/commit/c4c49ecc2d058e28e1ae6d5ca8fae72d03233cfd#commitcomment-21148819

Example dummy phoenix project: https://github.com/wojtekmach/phoenix_example/tree/master/dummy/test

Example dummy phoenix project (umbrella): https://github.com/wojtekmach/phoenix_example/tree/master/dummy_umbrella

Example tests on hex_web: https://github.com/hexpm/hex_web/tree/3f32fef19badef677b4a44a5e253b1ddef84f85e/test

josevalim: For what is worth, I wouldn't worry too much about tooling because "mix
test --stale" beats any tooling out there. :) but being consistent is good!
-- 


*José Valimwww.plataformatec.com.br
<http://www.plataformatec.com.br/>Founder and Director of R&D*

scmx: @wojtekmach I did a rebase on latest master to try this out, if you're interested you can see how I solved the merge conflicts here: https://github.com/scmx/phoenix/commits/wm-generators-test

I think it's good to be consistent with matching file paths in lib and test regardless of tooling. 👍 
wojtekmach: @scmx I've cherry-picked the commits to this branch, thank you!
wojtekmach: Finally rebased. The example project (https://github.com/wojtekmach/phoenix_example/tree/master) has been updated as well.
chrismccord: Can you address the conflicts? Should be good to go after that. Thanks!!!

Patch:
diff --git a/installer/lib/phx_new/single.ex b/installer/lib/phx_new/single.ex
index bd7a126b3..626cb5283 100644
--- a/installer/lib/phx_new/single.ex
+++ b/installer/lib/phx_new/single.ex
@@ -22,9 +22,9 @@ defmodule Phx.New.Single do
     {:eex,  "phx_test/support/channel_case.ex",         :project, "test/support/channel_case.ex"},
     {:eex,  "phx_test/support/conn_case.ex",            :project, "test/support/conn_case.ex"},
     {:eex,  "phx_single/test/test_helper.exs",          :project, "test/test_helper.exs"},
-    {:keep, "phx_test/channels",                        :project, "test/web/channels"},
-    {:keep, "phx_test/controllers",                     :project, "test/web/controllers"},
-    {:eex,  "phx_test/views/error_view_test.exs",       :project, "test/web/views/error_view_test.exs"},
+    {:keep, "phx_test/channels",                        :project, "test/:app/web/channels"},
+    {:keep, "phx_test/controllers",                     :project, "test/:app/web/controllers"},
+    {:eex,  "phx_test/views/error_view_test.exs",       :project, "test/:app/web/views/error_view_test.exs"},
   ]
 
   template :gettext, [
@@ -58,9 +58,9 @@ defmodule Phx.New.Single do
     {:eex, "phx_web/templates/page/index.html.eex",          :project, "lib/:app/web/templates/page/index.html.eex"},
     {:eex, "phx_web/views/layout_view.ex",                   :project, "lib/:app/web/views/layout_view.ex"},
     {:eex, "phx_web/views/page_view.ex",                     :project, "lib/:app/web/views/page_view.ex"},
-    {:eex, "phx_test/controllers/page_controller_test.exs",  :project, "test/web/controllers/page_controller_test.exs"},
-    {:eex, "phx_test/views/layout_view_test.exs",            :project, "test/web/views/layout_view_test.exs"},
-    {:eex, "phx_test/views/page_view_test.exs",              :project, "test/web/views/page_view_test.exs"},
+    {:eex, "phx_test/controllers/page_controller_test.exs",  :project, "test/:app/web/controllers/page_controller_test.exs"},
+    {:eex, "phx_test/views/layout_view_test.exs",            :project, "test/:app/web/views/layout_view_test.exs"},
+    {:eex, "phx_test/views/page_view_test.exs",              :project, "test/:app/web/views/page_view_test.exs"},
   ]
 
   template :bare, [
diff --git a/installer/lib/phx_new/web.ex b/installer/lib/phx_new/web.ex
index 24c71394b..dd5d7e1be 100644
--- a/installer/lib/phx_new/web.ex
+++ b/installer/lib/phx_new/web.ex
@@ -21,12 +21,12 @@ defmodule Phx.New.Web do
     {:eex,  "phx_web/views/error_view.ex",            :web, "lib/:web_app/views/error_view.ex"},
     {:eex,  "#{@pre}/mix.exs",                        :web, "mix.exs"},
     {:eex,  "#{@pre}/README.md",                      :web, "README.md"},
-    {:keep, "phx_test/channels",                      :web, "test/channels"},
-    {:keep, "phx_test/controllers",                   :web, "test/controllers"},
+    {:keep, "phx_test/channels",                      :web, "test/:web_app/channels"},
+    {:keep, "phx_test/controllers",                   :web, "test/:web_app/controllers"},
     {:eex,  "#{@pre}/test/test_helper.exs",           :web, "test/test_helper.exs"},
     {:eex,  "phx_test/support/channel_case.ex",       :web, "test/support/channel_case.ex"},
     {:eex,  "phx_test/support/conn_case.ex",          :web, "test/support/conn_case.ex"},
-    {:eex,  "phx_test/views/error_view_test.exs",     :web, "test/views/error_view_test.exs"},
+    {:eex,  "phx_test/views/error_view_test.exs",     :web, "test/:web_app/views/error_view_test.exs"},
   ]
 
   template :gettext, [
@@ -53,9 +53,9 @@ defmodule Phx.New.Web do
     {:eex,  "phx_web/templates/page/index.html.eex",          :web, "lib/:web_app/templates/page/index.html.eex"},
     {:eex,  "phx_web/views/layout_view.ex",                   :web, "lib/:web_app/views/layout_view.ex"},
     {:eex,  "phx_web/views/page_view.ex",                     :web, "lib/:web_app/views/page_view.ex"},
-    {:eex,  "phx_test/controllers/page_controller_test.exs",  :web, "test/controllers/page_controller_test.exs"},
-    {:eex,  "phx_test/views/layout_view_test.exs",            :web, "test/views/layout_view_test.exs"},
-    {:eex,  "phx_test/views/page_view_test.exs",              :web, "test/views/page_view_test.exs"},
+    {:eex,  "phx_test/controllers/page_controller_test.exs",  :web, "test/:web_app/controllers/page_controller_test.exs"},
+    {:eex,  "phx_test/views/layout_view_test.exs",            :web, "test/:web_app/views/layout_view_test.exs"},
+    {:eex,  "phx_test/views/page_view_test.exs",              :web, "test/:web_app/views/page_view_test.exs"},
   ]
 
   template :bare, [
diff --git a/lib/mix/phoenix.ex b/lib/mix/phoenix.ex
index 020302b6e..555a67a32 100644
--- a/lib/mix/phoenix.ex
+++ b/lib/mix/phoenix.ex
@@ -225,6 +225,10 @@ defmodule Mix.Phoenix do
     Path.join([app_path!(ctx_app, otp_app()), "lib", to_string(ctx_app), rel_path])
   end
 
+  def context_test_path(ctx_app, rel_path \\ "") when is_atom(ctx_app) do
+    Path.join([app_path!(ctx_app, otp_app()), "test", to_string(ctx_app), rel_path])
+  end
+
   @doc """
   Returns the otp context app.
   """
@@ -240,11 +244,13 @@ defmodule Mix.Phoenix do
   @doc """
   Returns the test prefix to be used in generated file specs.
   """
-  def web_test_path(ctx_app) when is_atom(ctx_app) do
-    if ctx_app == otp_app() do
-      Path.join(File.cwd!(), "test/web")
+  def web_test_path(ctx_app, rel_path \\ "") when is_atom(ctx_app) do
+    this_app = otp_app()
+
+    if ctx_app == this_app do
+      Path.join(["test", to_string(this_app), "web", rel_path])
     else
-      Path.join(File.cwd!(), "test")
+      Path.join(["test", to_string(this_app), rel_path])
     end
   end
 
diff --git a/lib/mix/phoenix/context.ex b/lib/mix/phoenix/context.ex
index ede11eec1..3283b300e 100644
--- a/lib/mix/phoenix/context.ex
+++ b/lib/mix/phoenix/context.ex
@@ -28,7 +28,7 @@ defmodule Mix.Phoenix.Context do
     alias     = module |> Module.split() |> tl() |> Module.concat()
     basename  = Phoenix.Naming.underscore(context_name)
     dir       = Mix.Phoenix.context_lib_path(ctx_app, basename)
-    test_dir  = Mix.Phoenix.context_app_path(ctx_app, "test")
+    test_dir  = Mix.Phoenix.context_test_path(ctx_app, basename)
     file      = Path.join([dir, basename <> ".ex"])
     test_file = Path.join([test_dir, basename <> "_test.exs"])
     generate? = Keyword.get(opts, :context, true)
diff --git a/lib/mix/tasks/phx.gen.channel.ex b/lib/mix/tasks/phx.gen.channel.ex
index 878f9b0c6..2c39bb510 100644
--- a/lib/mix/tasks/phx.gen.channel.ex
+++ b/lib/mix/tasks/phx.gen.channel.ex
@@ -13,12 +13,12 @@ defmodule Mix.Tasks.Phx.Gen.Channel do
   For a regular application:
 
     * a channel in lib/my_app/web/channels
-    * a channel_test in test/web/channels
+    * a channel_test in test/my_app/web/channels
 
   For an umbrella application:
 
     * a channel in lib/my_app/channels
-    * a channel_test in test/channels
+    * a channel_test in test/my_app/channels
 
   """
   use Mix.Task


Test patch:
diff --git a/installer/test/phx_new_test.exs b/installer/test/phx_new_test.exs
index 819514c00..f3e310d60 100644
--- a/installer/test/phx_new_test.exs
+++ b/installer/test/phx_new_test.exs
@@ -49,10 +49,10 @@ defmodule Mix.Tasks.Phx.NewTest do
       end
       assert_file "phx_blog/lib/phx_blog/web/endpoint.ex", ~r/defmodule PhxBlog.Web.Endpoint do/
 
-      assert_file "phx_blog/test/web/controllers/page_controller_test.exs"
-      assert_file "phx_blog/test/web/views/page_view_test.exs"
-      assert_file "phx_blog/test/web/views/error_view_test.exs"
-      assert_file "phx_blog/test/web/views/layout_view_test.exs"
+      assert_file "phx_blog/test/phx_blog/web/controllers/page_controller_test.exs"
+      assert_file "phx_blog/test/phx_blog/web/views/page_view_test.exs"
+      assert_file "phx_blog/test/phx_blog/web/views/error_view_test.exs"
+      assert_file "phx_blog/test/phx_blog/web/views/layout_view_test.exs"
       assert_file "phx_blog/test/support/conn_case.ex"
       assert_file "phx_blog/test/test_helper.exs"
 
@@ -125,7 +125,7 @@ defmodule Mix.Tasks.Phx.NewTest do
       assert File.exists?("phx_blog/lib/phx_blog/web/channels")
       assert_file "phx_blog/lib/phx_blog/web/channels/user_socket.ex", ~r"defmodule PhxBlog.Web.UserSocket"
       assert_file "phx_blog/lib/phx_blog/web/endpoint.ex", ~r"socket \"/socket\", PhxBlog.Web.UserSocket"
-      assert File.exists?("phx_blog/test/web/channels")
+      assert File.exists?("phx_blog/test/phx_blog/web/channels")
 
       # Gettext
       assert_file "phx_blog/lib/phx_blog/web/gettext.ex", ~r"defmodule PhxBlog.Web.Gettext"
@@ -166,7 +166,7 @@ defmodule Mix.Tasks.Phx.NewTest do
       assert_file "phx_blog/lib/phx_blog/web/web.ex", &refute(&1 =~ ~r"alias PhxBlog.Repo")
 
       # No HTML
-      assert File.exists?("phx_blog/test/web/controllers")
+      assert File.exists?("phx_blog/test/phx_blog/web/controllers")
 
       assert File.exists?("phx_blog/lib/phx_blog/web/controllers")
       assert File.exists?("phx_blog/lib/phx_blog/web/views")
diff --git a/installer/test/phx_new_umbrella_test.exs b/installer/test/phx_new_umbrella_test.exs
index b67ef34a0..ce32d28f6 100644
--- a/installer/test/phx_new_umbrella_test.exs
+++ b/installer/test/phx_new_umbrella_test.exs
@@ -82,10 +82,10 @@ defmodule Mix.Tasks.Phx.New.UmbrellaTest do
         assert file =~ "use Phoenix.View, root: \"lib/phx_umb_web/templates\""
       end
       assert_file web_path(@app, "lib/#{@app}_web/endpoint.ex"), ~r/defmodule PhxUmb.Web.Endpoint do/
-      assert_file web_path(@app, "test/controllers/page_controller_test.exs")
-      assert_file web_path(@app, "test/views/page_view_test.exs")
-      assert_file web_path(@app, "test/views/error_view_test.exs")
-      assert_file web_path(@app, "test/views/layout_view_test.exs")
+      assert_file web_path(@app, "test/#{@app}_web/controllers/page_controller_test.exs")
+      assert_file web_path(@app, "test/#{@app}_web/views/page_view_test.exs")
+      assert_file web_path(@app, "test/#{@app}_web/views/error_view_test.exs")
+      assert_file web_path(@app, "test/#{@app}_web/views/layout_view_test.exs")
       assert_file web_path(@app, "test/support/conn_case.ex")
       assert_file web_path(@app, "test/test_helper.exs")
 
@@ -99,7 +99,7 @@ defmodule Mix.Tasks.Phx.New.UmbrellaTest do
       assert_file web_path(@app, "lib/#{@app}_web/templates/layout/app.html.eex"),
                   "<title>Hello PhxUmb!</title>"
 
-      assert_file web_path(@app, "test/views/page_view_test.exs"),
+      assert_file web_path(@app, "test/#{@app}_web/views/page_view_test.exs"),
                   "defmodule PhxUmb.Web.PageViewTest"
 
       # Brunch
@@ -215,7 +215,7 @@ defmodule Mix.Tasks.Phx.New.UmbrellaTest do
       assert_file web_path(@app, "config/prod.secret.exs"), &refute(&1 =~ config)
 
       # No HTML
-      assert File.exists?(web_path(@app, "test/controllers"))
+      assert File.exists?(web_path(@app, "test/#{@app}_web/controllers"))
       assert File.exists?(web_path(@app, "lib/#{@app}_web/controllers"))
       assert File.exists?(web_path(@app, "lib/#{@app}_web/views"))
       refute File.exists?(web_path(@app, "test/controllers/pager_controller_test.exs"))
@@ -453,10 +453,10 @@ defmodule Mix.Tasks.Phx.New.UmbrellaTest do
         assert_file "another/lib/another.ex", ~r/defmodule Another do/
         assert_file "another/lib/another/endpoint.ex", ~r/defmodule Another.Endpoint do/
 
-        assert_file "another/test/controllers/page_controller_test.exs"
-        assert_file "another/test/views/page_view_test.exs"
-        assert_file "another/test/views/error_view_test.exs"
-        assert_file "another/test/views/layout_view_test.exs"
+        assert_file "another/test/another/controllers/page_controller_test.exs"
+        assert_file "another/test/another/views/page_view_test.exs"
+        assert_file "another/test/another/views/error_view_test.exs"
+        assert_file "another/test/another/views/layout_view_test.exs"
         assert_file "another/test/support/conn_case.ex"
         assert_file "another/test/test_helper.exs"
 
diff --git a/test/mix/tasks/phx.gen.channel_test.exs b/test/mix/tasks/phx.gen.channel_test.exs
index e8553b1f1..e14da0281 100644
--- a/test/mix/tasks/phx.gen.channel_test.exs
+++ b/test/mix/tasks/phx.gen.channel_test.exs
@@ -29,7 +29,7 @@ defmodule Mix.Tasks.Phx.Gen.ChannelTest do
         assert file =~ ~S|{:noreply, socket}|
       end
 
-      assert_file "test/web/channels/room_channel_test.exs", fn file ->
+      assert_file "test/phoenix/web/channels/room_channel_test.exs", fn file ->
         assert file =~ ~S|defmodule Phoenix.Web.RoomChannelTest|
         assert file =~ ~S|use Phoenix.Web.ChannelCase|
         assert file =~ ~S|alias Phoenix.Web.RoomChannel|
@@ -60,7 +60,7 @@ defmodule Mix.Tasks.Phx.Gen.ChannelTest do
         assert file =~ ~S|use Phoenix.Web, :channel|
       end
 
-      assert_file "test/web/channels/admin/room_channel_test.exs", fn file ->
+      assert_file "test/phoenix/web/channels/admin/room_channel_test.exs", fn file ->
         assert file =~ ~S|defmodule Phoenix.Web.Admin.RoomChannelTest|
         assert file =~ ~S|use Phoenix.Web.ChannelCase|
         assert file =~ ~S|alias Phoenix.Web.Admin.RoomChannel|
diff --git a/test/mix/tasks/phx.gen.context_test.exs b/test/mix/tasks/phx.gen.context_test.exs
index 1a4bdb08b..642992d23 100644
--- a/test/mix/tasks/phx.gen.context_test.exs
+++ b/test/mix/tasks/phx.gen.context_test.exs
@@ -36,7 +36,7 @@ defmodule Mix.Tasks.Phx.Gen.ContextTest do
 
       assert String.ends_with?(context.dir, "lib/phoenix/blog")
       assert String.ends_with?(context.file, "lib/phoenix/blog/blog.ex")
-      assert String.ends_with?(context.test_file, "test/blog_test.exs")
+      assert String.ends_with?(context.test_file, "test/phoenix/blog/blog_test.exs")
       assert String.ends_with?(context.schema.file, "lib/phoenix/blog/post.ex")
     end
   end
@@ -54,7 +54,7 @@ defmodule Mix.Tasks.Phx.Gen.ContextTest do
       assert Context.pre_existing?(context)
       refute Context.pre_existing_tests?(context)
 
-      File.mkdir_p!("test")
+      File.mkdir_p!("test/phoenix/blog")
       File.write!(context.test_file, """
       defmodule Phoenix.BlogTest do
       end
@@ -104,7 +104,7 @@ defmodule Mix.Tasks.Phx.Gen.ContextTest do
         assert file =~ "def change_post"
       end
 
-      assert_file "test/blog_test.exs", fn file ->
+      assert_file "test/phoenix/blog/blog_test.exs", fn file ->
         assert file =~ "use Phoenix.DataCase"
         assert file =~ "describe \"posts\" do"
         assert file =~ "def post_fixture(attrs \\\\ %{})"
@@ -122,7 +122,7 @@ defmodule Mix.Tasks.Phx.Gen.ContextTest do
         assert file =~ "field :title, :string"
       end
 
-      assert_file "test/blog_test.exs", fn file ->
+      assert_file "test/phoenix/blog/blog_test.exs", fn file ->
         assert file =~ "use Phoenix.DataCase"
         assert file =~ "describe \"comments\" do"
         assert file =~ "def comment_fixture(attrs \\\\ %{})"
@@ -161,7 +161,7 @@ defmodule Mix.Tasks.Phx.Gen.ContextTest do
         assert file =~ "raise \"TODO\""
       end
 
-      assert_file "test/blog_test.exs", fn file ->
+      assert_file "test/phoenix/blog/blog_test.exs", fn file ->
         assert file =~ "use Phoenix.DataCase"
         assert file =~ "describe \"posts\" do"
         assert file =~ "def post_fixture(attrs \\\\ %{})"
diff --git a/test/mix/tasks/phx.gen.html_test.exs b/test/mix/tasks/phx.gen.html_test.exs
index 3ed6f3ef9..0ef2f3045 100644
--- a/test/mix/tasks/phx.gen.html_test.exs
+++ b/test/mix/tasks/phx.gen.html_test.exs
@@ -44,7 +44,7 @@ defmodule Mix.Tasks.Phx.Gen.HtmlTest do
 
       assert_file "lib/phoenix/blog/post.ex"
       assert_file "lib/phoenix/blog/blog.ex"
-      assert_file "test/blog_test.exs", fn file ->
+      assert_file "test/phoenix/blog/blog_test.exs", fn file ->
         assert file =~ "alarm: ~T[15:01:01.000000]"
         assert file =~ "announcement_date: ~D[2010-04-17]"
         assert file =~ "deleted_at: ~N[2010-04-17 14:00:00.000000]"
@@ -58,7 +58,7 @@ defmodule Mix.Tasks.Phx.Gen.HtmlTest do
         assert file =~ "assert post.cost == Decimal.new(\"120.5\")"
       end
 
-      assert_file "test/web/controllers/post_controller_test.exs", fn file ->
+      assert_file "test/phoenix/web/controllers/post_controller_test.exs", fn file ->
         assert file =~ "defmodule Phoenix.Web.PostControllerTest"
         assert file =~ " post_path(conn"
       end
@@ -117,7 +117,7 @@ defmodule Mix.Tasks.Phx.Gen.HtmlTest do
       Gen.Html.run(~w(Blog Comment comments title:string))
       assert_file "lib/phoenix/blog/comment.ex"
 
-      assert_file "test/web/controllers/comment_controller_test.exs", fn file ->
+      assert_file "test/phoenix/web/controllers/comment_controller_test.exs", fn file ->
         assert file =~ "defmodule Phoenix.Web.CommentControllerTest"
       end
 
@@ -152,7 +152,7 @@ defmodule Mix.Tasks.Phx.Gen.HtmlTest do
     in_tmp_project config.test, fn ->
       Gen.Html.run(~w(Blog Post posts title:string --web Blog))
 
-      assert_file "test/web/controllers/blog/post_controller_test.exs", fn file ->
+      assert_file "test/phoenix/web/controllers/blog/post_controller_test.exs", fn file ->
         assert file =~ "defmodule Phoenix.Web.Blog.PostControllerTest"
         assert file =~ " blog_post_path(conn"
       end
@@ -189,7 +189,7 @@ defmodule Mix.Tasks.Phx.Gen.HtmlTest do
       refute_file "lib/phoenix/blog/comment.ex"
       assert Path.wildcard("priv/repo/migrations/*.exs") == []
 
-      assert_file "test/web/controllers/comment_controller_test.exs", fn file ->
+      assert_file "test/phoenix/web/controllers/comment_controller_test.exs", fn file ->
         assert file =~ "defmodule Phoenix.Web.CommentControllerTest"
       end
 
@@ -213,7 +213,7 @@ defmodule Mix.Tasks.Phx.Gen.HtmlTest do
       refute_file "lib/phoenix/blog/comment.ex"
       assert Path.wildcard("priv/repo/migrations/*.exs") == []
 
-      assert_file "test/web/controllers/comment_controller_test.exs", fn file ->
+      assert_file "test/phoenix/web/controllers/comment_controller_test.exs", fn file ->
         assert file =~ "defmodule Phoenix.Web.CommentControllerTest"
       end
 
@@ -248,7 +248,7 @@ defmodule Mix.Tasks.Phx.Gen.HtmlTest do
           assert file =~ "defmodule Phoenix.Web.UserView"
         end
 
-        assert_file "test/web/controllers/user_controller_test.exs", fn file ->
+        assert_file "test/phoenix/web/controllers/user_controller_test.exs", fn file ->
           assert file =~ "defmodule Phoenix.Web.UserControllerTest"
         end
       end
@@ -283,7 +283,7 @@ defmodule Mix.Tasks.Phx.Gen.HtmlTest do
           assert file =~ "defmodule Phoenix.Web.UserView"
         end
 
-        assert_file "test/controllers/user_controller_test.exs", fn file ->
+        assert_file "test/phoenix/controllers/user_controller_test.exs", fn file ->
           assert file =~ "defmodule Phoenix.Web.UserControllerTest"
         end
       end
diff --git a/test/mix/tasks/phx.gen.json_test.exs b/test/mix/tasks/phx.gen.json_test.exs
index b7ea9ba47..68ef7a961 100644
--- a/test/mix/tasks/phx.gen.json_test.exs
+++ b/test/mix/tasks/phx.gen.json_test.exs
@@ -41,11 +41,11 @@ defmodule Mix.Tasks.Phx.Gen.JsonTest do
       assert_file "lib/phoenix/blog/post.ex"
       assert_file "lib/phoenix/blog/blog.ex"
 
-      assert_file "test/blog_test.exs", fn file ->
+      assert_file "test/phoenix/blog/blog_test.exs", fn file ->
         assert file =~ "use Phoenix.DataCase"
       end
 
-      assert_file "test/web/controllers/post_controller_test.exs", fn file ->
+      assert_file "test/phoenix/web/controllers/post_controller_test.exs", fn file ->
         assert file =~ "defmodule Phoenix.Web.PostControllerTest"
       end
 
@@ -79,7 +79,7 @@ defmodule Mix.Tasks.Phx.Gen.JsonTest do
     in_tmp_project config.test, fn ->
       Gen.Json.run(~w(Blog Post posts title:string --web Blog))
 
-      assert_file "test/web/controllers/blog/post_controller_test.exs", fn file ->
+      assert_file "test/phoenix/web/controllers/blog/post_controller_test.exs", fn file ->
         assert file =~ "defmodule Phoenix.Web.Blog.PostControllerTest"
         assert file =~ " blog_post_path(conn"
       end
@@ -115,7 +115,7 @@ defmodule Mix.Tasks.Phx.Gen.JsonTest do
       refute_file "lib/phoenix/blog/comment.ex"
       assert Path.wildcard("priv/repo/migrations/*.exs") == []
 
-      assert_file "test/web/controllers/comment_controller_test.exs", fn file ->
+      assert_file "test/phoenix/web/controllers/comment_controller_test.exs", fn file ->
         assert file =~ "defmodule Phoenix.Web.CommentControllerTest"
       end
 
@@ -138,7 +138,7 @@ defmodule Mix.Tasks.Phx.Gen.JsonTest do
       refute_file "lib/phoenix/blog/comment.ex"
       assert Path.wildcard("priv/repo/migrations/*.exs") == []
 
-      assert_file "test/web/controllers/comment_controller_test.exs", fn file ->
+      assert_file "test/phoenix/web/controllers/comment_controller_test.exs", fn file ->
         assert file =~ "defmodule Phoenix.Web.CommentControllerTest"
       end
 
@@ -170,7 +170,7 @@ defmodule Mix.Tasks.Phx.Gen.JsonTest do
           assert file =~ "defmodule Phoenix.Web.UserView"
         end
 
-        assert_file "test/web/controllers/user_controller_test.exs", fn file ->
+        assert_file "test/phoenix/web/controllers/user_controller_test.exs", fn file ->
           assert file =~ "defmodule Phoenix.Web.UserControllerTest"
         end
       end
@@ -204,7 +204,7 @@ defmodule Mix.Tasks.Phx.Gen.JsonTest do
           assert file =~ "defmodule Phoenix.Web.UserView"
         end
 
-        assert_file "test/controllers/user_controller_test.exs", fn file ->
+        assert_file "test/phoenix/controllers/user_controller_test.exs", fn file ->
           assert file =~ "defmodule Phoenix.Web.UserControllerTest"
         end
       end