   describe "index" do
 
     test "lists all entries on index", %{conn: conn} do
-      conn = get conn, user_path(conn, :index)
-      assert json_response(conn, 200)["data"] == []
+      [user_1, user_2] = insert_pair(:user)
+
+      conn
+      |> request_index
+      |> json_response(200)
+      |> assert_ids_from_response([user_1.id, user_2.id])
     end
 
     test "filters resources on index", %{conn: conn} do
-      [user_1, user_2] = insert_pair(:user)
-      insert(:user, username: "user_3", email: "user_3@mail.com")
-      conn = get conn, "users/?filter[id]=#{user_1.id},#{user_2.id}"
-      data = json_response(conn, 200)["data"]
-      [first_result, second_result | _] = data
-      assert length(data) == 2
-      assert first_result["id"] == "#{user_1.id}"
-      assert second_result["id"] == "#{user_2.id}"
-    end
-  end
-
-  describe "#show" do
-
+      [user_1, user_2 | _] = insert_list(3, :user)
+
+      path = "users/?filter[id]=#{user_1.id},#{user_2.id}"
+
+      conn
+      |> get(path)
+      |> json_response(200)
+      |> assert_ids_from_response([user_1.id, user_2.id])
+    end
+  end
+
+  describe "show" do
     test "shows chosen resource", %{conn: conn} do
       user = insert(:user)
-      conn = get conn, user_path(conn, :show, user)
-      data = json_response(conn, 200)["data"]
-      assert data["id"] == "#{user.id}"
-      assert data["type"] == "user"
-      assert data["attributes"]["username"] == user.username
-      assert data["attributes"]["email"] == ""
-      assert data["attributes"]["password"] == nil
-    end
-
-    test "renders email when authenticated", %{conn: conn} do
-      user = insert(:user)
-      path = conn |> user_path(:show, user)
-      json = conn |> authenticate(user) |> get(path) |> json_response(200)
-
-      assert json["data"]["attributes"]["email"] == user.email
+      conn
+      |> request_show(user)
+      |> json_response(200)
+      |> Map.get("data")
+      |> assert_result_id(user.id)
+    end
+
+    @tag :authenticated
+    test "renders email when authenticated", %{conn: conn, current_user: current_user} do
+      assert conn |> request_show(current_user) |> json_response(200)
     end
 
     test "renders 404 when id is nonexistent", %{conn: conn} do
-      path = conn |> user_path(:show, -1)
-      assert conn |> get(path) |> json_response(404)
+      assert conn |> request_show(:not_found) |> json_response(404)
     end
   end
 


      path = user_path(conn, :update, user)

      conn =
        conn
        |> authenticate(user)
        |> put(path, params)

      id = json_response(conn, 200)["data"]["id"]
      assert id
      user =  Repo.get(User, id)
      assert user.email == "test@user.com"
      assert user.first_name == "Test"
      assert user.last_name == "User"
      assert user.website == "http://www.example.com"
      assert user.biography == "Just a test user"
    end

    test "tracks authentication & update profile events in Segment", %{conn: conn} do

    end

    test "does not create resource and renders errors when data is invalid", %{conn: conn} do
      attrs = Map.put(@invalid_attrs, :password, "password")
      conn = post conn, user_path(conn, :create), %{
        "data" => %{
          "attributes" => attrs
        }
      }

      assert conn |> json_response(422)
    end
  end

  describe "update" do
    @tag :authenticated
    test "updates and renders chosen resource when data is valid", %{conn: conn} do
      user = insert(:user)
      attrs = Map.put(@valid_attrs, :password, "password")
