in the example of Rahab, if she had volunteered the location of the spies to the rulers of Jericho, she would have indeed betrayed them; but to refuse to disclose their location instead of lying that they had left her house would probably have led to her own arrest and the arrest of the israelite spies - so the logical question is, would God have supernaturally protected them as he did Shadrach, Meshach, and Abednego, and Daniel? well, were the spies following God's instructions? what did Jesus say about such a situation?
Mar 13:9-13 KJV
(9) But take heed to yourselves: for they shall deliver you up to councils; and in the synagogues ye shall be beaten: and ye shall be brought before rulers and kings for my sake, for a testimony against them.
(10) And the gospel must first be published among all nations.
(11) But when they shall lead you, and deliver you up, take no thought beforehand what ye shall speak, neither do ye premeditate: but whatsoever shall be given you in that hour, that speak ye: for it is not ye that speak, but the Holy Ghost.
(12) Now the brother shall betray the brother to death, and the father the son; and children shall rise up against their parents, and shall cause them to be put to death.
(13) And ye shall be hated of all men for my name's sake: but he that shall endure unto the end, the same shall be saved.
the question remains; would God who hates lies lead someone to lie?