Assuming you're referring to a common house spider, they will typically stay in your room as long as there is food and water available, and the temperature is suitable. If any of these conditions change, the spider may leave in search of a more ideal environment.