Was Rahab a saved person when the spies went to her home?
I think you’ve raised a good question. We must also recognize that the exact point at which a person is saved may not be known. When, for example, were each of the disciples saved?
The point James is making is that while faith alone is the basis for one's salvation, men and women are recognized as believers by their fruits (compare Matthew 7:16). Abraham was declared righteous by God in Genesis 15:6, because He can know men's hearts. But we see that Abraham was a believer when he offered up Isaac.
So it was with Rahab. She was already a believer (but we are not sure when this happened in time) when she risked her life when she protected the two spies. Here actions at this time were a demonstration of her faith. When did she come to faith? I'm not so sure about that. By her own words, it was not just Rahab, but many of those of her people who had heard of the exodus — the parting the Red Sea, the defeat of Israel's enemies — were terrified by the arrival of the Israelites. But they did not believe. They were like the demons in James 2, who knew the truth and shuddered, but did not trust in God. Rahab went further. She knew that the God of Israel was great, and she entrusted herself to Him, through these Israelites. The long and the short of it is that her actions in protecting the spies demonstrated her faith, but we are told little more. It is clear, however, that she is one of the household of faith.
I have no doubt that God saves such folks as Rahab. Texts such as John 8:1-11; 1 Corinthians 1:26-31; 6:9-11 (emphasis here on such “were” some of you) make this abundantly clear.