What does "to spit a rat" mean?

Solution 1:

The original coinage seems to be from Ira Wolfert's 1943 novel Tucker's People, as...

I'd kill you just as fast as I'd spit a rat out of my mouth, you son of a bitch.

Much later in The Hitchhiker's Guide to the Galaxy (1989), Douglas Adams picked it up as...

I wouldn't trust myself further than I could spit a rat.

I have to admit I find Adams' usage "odd". I'd expect the the imagery to focus on how quickly you want that rat out of your mouth, not how far away from your mouth you want to eject it.

Usually when talking about how "[not] far" we trust someone, the image focusses on what a short distance that is (as far as I could throw him). The reader has no special wish to imagine throwing [him] at all - he just knows if he did, it wouldn't be very far. He doesn't "want more" distance; rather he "accepts it will be less".

But on imagining a rat in his mouth, apart from the fact that primarily the reader wants it out fast, he naturally "wants more" distance, because it's repulsive. That's why it's an "odd" usage - the reader's "more distance" inclination works against the writer's "less distance" intention.

The "spit a rat" usage isn't particularly common anyway, but (possibly because Adams is more well-known than Wolfert), the "not far" sense seems more prevalent than "very fast".

I agree with Joel Brown that Adams' was probably being deliberately quirky, and knew he was mangling the original meaning (it's almost a "mixed metaphor" to me). But I doubt he expected it to be so closely scrutinised - here on ELU, or anywhere else for that matter!

Solution 2:

This kind of expression – an image that alludes to a relatively short distance – is often used to convey a lack of trust:

"I wouldn't trust him as far as I could throw him."

is probably the most common. A variation is:

"I woudn't trust him as far as I could kick him."

Yet another version:

"I wouldn't trust him as far as I could spit."

Adams is a rather original author; it's no surprise he has found a way to give a relatively common expression a unique twist. A rat seems like a good choice, too, since rats are a spittable size, and "rat" is a derogatory slang term often hung on those who can't be trusted – particularly those who have betrayed some circle.

Google search results: 
I wouldn't trust him as far as I could throw him: 77,000+  
I wouldn't trust him as far as I could kick him: 3,000+  
I wouldn't trust him as far as I could spit: almost 5,000  
I wouldn't trust him as far as I could spit a rat: 7  
(all searches in quotes)

Solution 3:

Adams's writing often uses double meaning that relies on being literal. That is to say that he tends to use idiomatic prose to evoke its literal meaning, or to simplify complex subjects to their most basic abstraction to create humour or point out absurdity.

For example, when talking about Earth, he sums up existential crisis, monetary trade, and the value of wealth as follows:

"This planet has — or rather had — a problem, which was this: most of the people living on it were unhappy for pretty much all of the time. Many solutions were suggested for this problem, but most of these were largely concerned with the movement of small green pieces of paper, which was odd because on the whole it wasn't the small green pieces of paper that were unhappy." [Hitchhiker's Guide To the Galaxy (book), chapter 1]

In this, the humour is from the fact that, quite literally, it is absurd to use the movement of green pieces of paper to remedy unhappiness on a large scale.

It is worth noting that Douglas Adams was a British writer, and in Europe, Brown and Black rats are most common. The average Brown Rat's body is in the region of 8 inches long (As noted here) they also, from personal experience have a diameter of around 1.5 inches. If you take into account their tail, it is probably fair to estimate their volume as a cylinder 8 inches long, and 1.5 inches in diameter, or about 14 cubic inches.

And so, my understanding of the passage:

What he is suggesting is the literal distance a human being (both Ford Prefect and Zaphod Beeblebrox are establish in visual media and in the books as being near-identical to humans externally, barring the occasional extra appendage.) could spit a rat (or, as Ford Prefect states at one point "Comfortably spit out a rat") in a physical sense. An average baseball has a similar volume to a rat, and a tennis ball is smaller. If you take a tennis ball as an idealized rat for spitting (significantly smaller, and immobile, but still hairy) and tried to spit it out, having somehow managed to lodge it in your mouth, you would run up against two problems: Large solid objects are hard to spit out, and hairy object are hard to spit out. You couldn't spit it very far. If you added the movement of a rodent thoroughly displeased with being in your mouth to that, and it may in fact be impossible to spit out a rat, or if possible, not possible to spit if far, and by analogy, not possible, or if possible not to a great extent, to trust the mentioned individual.

Solution 4:

An Elephind search produces an instance of "spit a rat" from Muriel Pollexfen, "A King's Pardon," in the Adelaide [South Australia] Chronicle (June 7, 1918):

But O'Halloran's pockets were empty and his stomach craved the wherewithal to procure it a hearty meal and a comforting bottle of port. And, he argued aloud, if 'twas that he, Nicholas O'Halloran, highway man and night-rider these thirty years, should fed a sinking of the heart as he journeyed, was it not to be concluded without a doubt that the hearts of those five gallants would be as watery as the running dykes edging the soaking roads? Sure! Victory would be as easy as picking plums, and 'twould be himself was the coward and the fool if he gave up so certain a fight! Fight! Why, 'troth! 'twas not one of them could spit a rat even if they had the pluck to try!

The wording at first seems rather bizarre: why would the act of spitting a rat out of one's mouth strike anyone as representing a low bar for bravery—as opposed to, say, evidence of extreme and unhygienic eccentricity? But another instance of the phrase, from almost half a century earlier, offers some clarity. From James Grant, Six Years Ago: A Novel (1870):

... Adderfang opened his eyes, gasping heavily the while, and a terror came over him on seeing the point of Gordon's sword within an inch of his throat.

"Ach, Gott in himmel! Would you kill me, herr major?" he moaned.

"With as little compunction as I would would spit a rat," said Gordon sternly.

Here, "spit" clearly means "impale as if on a spit."

Similar early instances involve the variant phrase "spitting a rat." From an untitled item in the [Sydney, New South Wales] Evening News (February 13, 1871):

One of the late illustrations professing to give scenes "Inside Paris" represents the night guard on duty in the sewers, and one of them, with an expression of eager voracity, which is participated in by his envying companions, dexterously spitting a rat on the point of his bayonet, as the animal swims through the water. Such sketches as these may be some what exaggerated but no doubt they have a broad basis of fact.

And from Edwin Pugh, "Borrowed Plumes," in Cassell's Magazine (July 1902):

"Liar! Coward!" exclaimed Gravely, stamping hard upon the ground. Persecutor of innocent women! Perjured slanderer! Fop! Fool! Villain! If you do not instantly draw your sword, by my forefather! I will run you through!And that with as little compunction as I should feel at spitting a rat!"

These examples raise the strong possibility that the 1918 instance, too, refers not to expectorating a rat from one's mouth but to impaling a rat with a sharp implement. Indeed, a search of the National Library of Australia's Trove database of old newspapers finds three instances of "spitted like a rat"—from the Adelaide [South Australia] Observer (February 10, 1883), the [Melbourne, Victoria] Age (October 24, 1896), and the [Adelaide, South Australia] Advertiser (October 3, 1914)—suggesting that the simile had a modest level of currency there in the half century from 1870 to 1920.

Obviously that is not a possible interpretation of the instance from Wolfert's 1943 novel (cited in Fumblefingers's answer); but, though improbable, it is not out of the question in the Adams example. Recent instances from 2001 (John Sandford, The Devil's Code) and 2008 (Kix Brooks & Ronnie Dunn, The Adventures of Slim & Howdy: A Novel) follow Adams in using the phrase as part of the lengthier notion of not trusting [someone] farther than [the speaker] could spit a rat.


Conclusion

In the period 1870–1920, the phrase "spit a rat" would probably have been understood to refer to impaling a rat on a spear, sword, bayonet, or other weapon; but from 1943 onward, the same phrase seems to have acquired the very different sense of expectorating a rat from one's mouth. The earlier act is easy to visualize as something that might happen in the real world; the latter appears to be an exaggerated act of great unpleasantness and no real-world possibility.