 
   describe "concerning catching errors" do
     setup do
-      conn =
-        %Plug.Conn{}
-        |> Plug.Conn.put_private(:phoenix_controller, "foo")
-        |> Plug.Conn.put_private(:phoenix_action, "bar")
+      try do
+        :get
+        |> conn("/exception", %{})
+        |> PhoenixWithAppSignal.call([])
+      catch
+        :error, %Plug.Conn.WrapperError{reason: %RuntimeError{message: "Exception!"}} ->
+          :ok
 
-      [conn: conn]
+        type, reason ->
+          {type, reason}
+      end
     end
 
-    test "reports an error for an exception", %{conn: conn, fake_transaction: fake_transaction} do
-      :ok =
-        try do
-          UsingAppsignalPhoenixWithException.call(conn, %{})
-        catch
-          :error, %RuntimeError{message: "exception!"} -> :ok
-          type, reason -> {type, reason}
-        end
-
+    test "reports an error for an exception", %{fake_transaction: fake_transaction} do
       assert FakeTransaction.started_transaction?(fake_transaction)
 
       assert [
                {
                  %Appsignal.Transaction{} = transaction,
                  "RuntimeError",
-                 "exception!",
+                 "Exception!",
                  _stack
                }
              ] = FakeTransaction.errors(fake_transaction)


  describe "concerning starting and finishing transactions" do
    setup do
      conn = UsingAppsignalPhoenix.call(%Plug.Conn{}, %{})

      {:ok, conn: conn}
    end

    test "starts a transaction", %{fake_transaction: fake_transaction} do
      assert FakeTransaction.started_transaction?(fake_transaction)
    end

    test "calls super and returns the conn", context do
      assert context[:conn].assigns[:called?]
    end

    test "finishes the transaction", %{fake_transaction: fake_transaction} do

defmodule PhoenixWithAppSignal do
  use Plug.Router
  use Appsignal.Phoenix
  use Plug.ErrorHandler

  plug(:match)
  plug(:dispatch)

  get "/" do
    send_resp(conn, 200, "Welcome")
  end

  get "/exception" do
    raise("Exception!")
    send_resp(conn, 200, "Welcome")
  end
end

defmodule Appsignal.PhoenixTest do
  use ExUnit.Case
  alias Appsignal.FakeTransaction
  use Plug.Test

  setup do
    {:ok, fake_transaction} = FakeTransaction.start_link()
