Cook the spaghetti according to package instructions and set aside. Save one cup of pasta water.
Heat 2 tablespoons of olive oil. Add the onions and garlic and sauté till well roasted. Add salt to speed up the process.
Add the rosemary and mix well. Sauté for about a minute.
Add a little bit more oil and then add the chickpeas and the spinach. Mix and sauté for about a minute. The spinach will start wilting and the chickpeas will start darkening.
Now add the heavy cream and mix well. Add salt and pepper and let it all simmer together for about 3-4 minutes. The chickpeas will soften, and the spinach will get cooked. If the sauce gets too thick, add a little but of the saved pasta water.
Take it off heat and add the cooked spaghetti. Combine well.