1. To cook the pasta, fill the pot halfway with water. Bring it to a boil over high heat. When the water is boiling, add the pasta and cook until just tender, about 12 minutes. Just before draining, reserve 1 1/2 cups of the pasta water. Drain the pasta and set aside.
2. While the pasta is cooking, cook the sauce: Put the skillet on the stove over medium-low heat and when it is hot, add the oil. Add the garlic, onion, carrots, celery, and rosemary and cook until the garlic is golden, about 15 minutes.
3. Add the chickpeas and using the fork, lightly mash half of them. Add the reserved pasta water and tomatoes and cook 10 minutes.
4. Add the pasta and spinach to the skillet mixture and cook until the spinach is tender and most of the liquid has been absorbed by the pasta, about 10 minutes. Add the red pepper flakes, if desired.
5. Mix well and serve immediately, garnished with Parmesan cheese.