This was a good edit, and it was correct to accept it.
The link is to an official reference about the book (the publisher's website). It provides useful information about the book, including its ISBN, its publication date and its table of content. If the book is to be mentioned at all, it is a lot better to provide such a link.
Adding the link is not spam. Mentioning the book is the act that may or may not make the post spammy. Given that the post does answer the question and that the code was written for the book, it is perfectly reasonable to mention the book.
“The book is easily googlable” is no reason not to provide the link. Providing the link is a lot more helpful to readers who happen to want to follow up on the book. Why should every reader do their own googling? It is much better for one person to look up the link, so that subsequent readers only need to click.
An edit does not have to add new information about the main topic of the post. Adding links for natural follow-ups is perfectly reasonable. When editing other people's posts, you should stick to links to sites that are commonly accepted references, which the author of the post wouldn't have minded using if he'd taken the time or thought to add the link. For example, adding a link to Wikipedia, or to the reference documentation of a library or tool, or to the official site of a book or piece of software, are all good things if the linked content is relevant for further information or clarification. Examples of bad edits would be linking to some random blog post on the topic (especially if it's an opinion piece or to your own blog).