Joshua had told the two men who had gone to explore the land, “Go to the house of Rahab the prostitute and bring her out together with all her family, as you promised.”
David summoned the Gibeonites and spoke with them. The Gibeonites were not Israelites, but what was left of the Amorites. The Israelites had sworn an oath to them, but in his nationalistic passion for the Israelites and Judah, Saul had tried to wipe them out.
However, the king spared Mephibosheth, son of Jonathan, son of Saul, because of the oath sworn before the Lord between David and Jonathan, son of Saul.
They reject people the Lord has rejected, but honor those who follow the Lord. They keep their promises even when it's hard to do. They don't change their minds.
He made an agreement with one of the royal family and made him take an oath that he would be a loyal subject as king. Then he took into exile the country's leaders,
As I live, declares the Lord God, ‘He is going to die in Babylon, in the country of the king who put him on the throne, whose oath he disregarded and whose agreement he broke.
The city and everything in it is to be set apart for the Lord and destroyed. Only Rahab the prostitute and all those with her in her house shall be spared, because she hid the spies we sent.
So the spies went and brought out Rahab, her father and mother, and all who were with her. They brought out the whole family and took them to a place near the Israelite camp.