From d8fd6aa84d0ef0433309c2d9f2772811b9409eee Mon Sep 17 00:00:00 2001 From: Andy Duong Date: Wed, 15 Mar 2023 23:04:50 +0700 Subject: [PATCH] [gh315] Fix the credo and the feature test --- lib/nimble_template/addons/credo.ex | 7 ++++--- .../test/features/home_page/view_home_page_test.exs.eex | 4 ++-- .../nimble_template/test/support/feature_case.ex.eex | 1 + .../addons/variants/phoenix/web/wallaby_test.exs | 2 ++ 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/nimble_template/addons/credo.ex b/lib/nimble_template/addons/credo.ex index 93042866..f0695bdc 100644 --- a/lib/nimble_template/addons/credo.ex +++ b/lib/nimble_template/addons/credo.ex @@ -62,9 +62,9 @@ defmodule NimbleTemplate.Addons.Credo do end defp edit_web_entry!( - %Project{web_path: web_path, web_module: web_module, web_project?: true} = project + %Project{web_path: web_path, web_module: web_module, mix_project?: false} = project ) do - Generator.delete_content!( + Generator.replace_content( "#{web_path}.ex", """ def verified_routes do @@ -75,7 +75,8 @@ defmodule NimbleTemplate.Addons.Credo do statics: #{web_module}.static_paths() end end - """ + """, + "" ) Generator.replace_content!( diff --git a/priv/templates/nimble_template/test/features/home_page/view_home_page_test.exs.eex b/priv/templates/nimble_template/test/features/home_page/view_home_page_test.exs.eex index 0f1ac282..f716eb66 100644 --- a/priv/templates/nimble_template/test/features/home_page/view_home_page_test.exs.eex +++ b/priv/templates/nimble_template/test/features/home_page/view_home_page_test.exs.eex @@ -2,8 +2,8 @@ defmodule <%= web_module %>.HomePage.ViewHomePageTest do use <%= web_module %>.FeatureCase, async: false feature "view home page", %{session: session} do - visit(session, Routes.page_path(<%= web_module %>.Endpoint, :index)) + visit(session, ~p"/") - assert_has(session, Query.text("Welcome to Phoenix!")) + assert_has(session, Query.text("Phoenix Framework")) end end diff --git a/priv/templates/nimble_template/test/support/feature_case.ex.eex b/priv/templates/nimble_template/test/support/feature_case.ex.eex index 03b63ffe..c327dfb0 100644 --- a/priv/templates/nimble_template/test/support/feature_case.ex.eex +++ b/priv/templates/nimble_template/test/support/feature_case.ex.eex @@ -8,6 +8,7 @@ defmodule <%= web_module %>.FeatureCase do <% end %> use Wallaby.Feature use Mimic + use <%= web_module %>, :verified_routes import <%= base_module %>.Factory import <%= web_module %>.Gettext diff --git a/test/nimble_template/addons/variants/phoenix/web/wallaby_test.exs b/test/nimble_template/addons/variants/phoenix/web/wallaby_test.exs index 4edbe8e3..cb2bfaaa 100644 --- a/test/nimble_template/addons/variants/phoenix/web/wallaby_test.exs +++ b/test/nimble_template/addons/variants/phoenix/web/wallaby_test.exs @@ -23,6 +23,7 @@ defmodule NimbleTemplate.Addons.Phoenix.Web.WallabyTest do use Wallaby.Feature use Mimic + use NimbleTemplateWeb, :verified_routes import NimbleTemplate.Factory import NimbleTemplateWeb.Gettext @@ -62,6 +63,7 @@ defmodule NimbleTemplate.Addons.Phoenix.Web.WallabyTest do use Wallaby.Feature use Mimic + use NimbleTemplateWeb, :verified_routes import NimbleTemplate.Factory import NimbleTemplateWeb.Gettext