Preheat oven to 180 degrees Celsius.
Line a flan dish with baking paper. Lay the pastry across the bottom and work up the sides. Pierce the surface with a fork to prevent it bubbling. Line with baking paper and weigh it down with dried beans.
Place in the oven to blind bake for 15 - 20 minutes. Remove from the oven and set aside to cool. Remove the dried beans and paper.
Heat the oil in a wide pan and add the onions and rosemary. Reduce the heat and saute for 25 minutes stirring regularly. The onions are ready when they have turned a golden brown colour.
Fill the part baked pastry shell with onions, add the raw spinach and top with ricotta.
Bake in the oven for 20 minutes until the spinach is wilted.